package com.cdp.web.controller.system;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cdp.common.core.domain.AjaxResult;
import com.cdp.common.core.domain.entity.*;
import com.cdp.common.utils.StringUtils;
import com.cdp.system.dto.*;
import com.cdp.system.service.*;
import com.cdp.system.vo.SandFineneVO;
import com.cdp.system.vo.SandFinenessVO;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

import static org.apache.commons.collections4.CollectionUtils.collect;

@RestController
@RequestMapping("/system/fineness")
public class SysSandFinenessController {
    @Autowired
    private IsysRegionService isysRegionService;
    @Autowired
    private ISysFlyashService sysFlyashService;

    @Autowired
    private ISysSandFinenesService sysSandFinenesService;

    @Autowired
    private ISysSandTypeService sysSandTypeService;

    @Autowired
    private ISysSandService sysSandService;

    @Autowired
    private ISysStoneGrainService sysStoneGrainService;

    @Autowired
    private ISysFlyashTypeService sysFlyashTypeService;

    @Autowired
    private ISysFlyashFinenessService sysFlyashFinenessService;

    @Autowired
    private ISysWaterReducerTypeService sysWaterReducerTypeService;

    @Autowired
    private ISysCementService sysCementService;

    @Autowired
    private ISysStoneService sysStoneService;

    @Autowired
    private ISysWaterReducerService sysWaterReducerService;

    @Autowired
    private ISysStoneSizeService stoneSizeService;

    @Autowired
    private ISysSourceNameService sysSourceNameService;
    @Autowired
    private ISysEfficiencyMerchantNameService sysEfficiencyMerchantNameService;


    @Autowired
    private ISysDeformationPerformanceService sysDeformationPerformanceService;

    @Autowired
    private ISysEfficiencyAgentService sysEfficiencyAgent;

    @Autowired
    private ISysDurabilityPerformanceService sysDurabilityPerformanceService;

    @Autowired
    private ISysWaterService waterService;

    @Autowired
    private ISysMineralPowderService sysMineralPowderService;

    @Autowired
    private SysOtherAdmixturesService sysOtherAdmixturesService;


    @Autowired
    private ISysWaterModelService sysWaterModelService;

    @Autowired
    private ISysSwellingagentService sysSwellingagentService;

    @Autowired
    private ISysCementModelService sysCementModelService;


    @Autowired
    private ISysCementStabilityService sysCementStabilityService;

    @Autowired
    private ISysStoneModelService sysStoneModelService;

    @Autowired
    private ISysStoneSpecificationService sysStoneSpecificationService;


    @Autowired
    private ISysStoneParticlesizedistributionService sysStoneParticlesizedistributionService;


    @Autowired
    private ISysMineralModelService sysMineralModelService;

    @Autowired
    private ISysOtherAdmixturesModelService sysOtherAdmixturesModelService;


    /**
     * 水型号模糊查询
     */
    @PostMapping("listLikeWaterModel")
    private AjaxResult listLikeWaterModel(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysWater> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysWater::getModel, name);
        }

        // 查询数据
        List<SysWater> list = waterService.list(wrapper);

        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getModel());
                    vo.setLabel(s.getModel());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 水泥型号模糊查询
     */

    @PostMapping("listLikeCementModel")
    private AjaxResult listLikeCementModel(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysCement> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysCement::getModel, name);
        }

        List<SysCement> list = sysCementService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getModel());
                    vo.setLabel(s.getModel());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 水泥 安全性模糊查询
     */
    @PostMapping("listLikeCementStability")
    private AjaxResult listLikeCementStability(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysCement> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysCement::getStability, name);
        }

        List<SysCement> list = sysCementService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getStability());
                    vo.setLabel(s.getStability());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 石头型号模糊查询
     */
    @PostMapping("listLikeStoneModel")
    private AjaxResult listLikeStoneModel(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysStone> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysStone::getModel, name);
        }

        List<SysStone> list = sysStoneService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getModel());
                    vo.setLabel(s.getModel());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 石头规格模糊
     */
    @PostMapping("listLikeStoneSpecification")
    private AjaxResult listLikeStoneSpecification(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysStone> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysStone::getStoneSpecification, name);
        }

        List<SysStone> list = sysStoneService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getStoneSpecification());
                    vo.setLabel(s.getStoneSpecification());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 石头颗粒级配模糊
     */


    @PostMapping("listLikeStoneParticlesizedistribution")
    private AjaxResult listLikeStoneParticlesizedistribution(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysStone> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysStone::getParticleSizeDistribution, name);
        }

        List<SysStone> list = sysStoneService.list(wrapper);

        // 使用 HashSet 去重
        HashSet<String> uniqueParticleSizeDistributions = new HashSet<>();

        List<SandFineneVO> sandFinenessVOList = new ArrayList<>();
        for (SysStone stone : list) {
            String particleSizeDistribution = stone.getParticleSizeDistribution();
            // 如果集合中不存在，则添加并创建对应的 VO 对象
            if (uniqueParticleSizeDistributions.add(particleSizeDistribution)) {
                SandFineneVO vo = new SandFineneVO();
                vo.setValue(particleSizeDistribution);
                vo.setLabel(particleSizeDistribution);
                sandFinenessVOList.add(vo);
            }
        }

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 砂细度下拉模糊
     *
     * @return
     */

    @PostMapping("listMistedSandFineness")
    private AjaxResult listMistedSandFineness(@RequestBody SandFinenessDTO sandFinenessDTO) {
        // 调用服务层方法获取结果
        List<SysSandFineness> sysFlyashFinenessList = sysSandFinenesService.listMistedSand(sandFinenessDTO);

        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = sysFlyashFinenessList.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 砂类型下拉模糊查询1
     *
     * @return
     */
    @PostMapping("listMistedSandType")
    private AjaxResult listMistedSandType(@RequestBody SandFinenessDTO sandFinenessDTO) {

        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysSand> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysSand::getType, name);
        }

        List<SysSand> list = sysSandService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getType());
                    vo.setLabel(s.getType());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);


    }


    /**
     * 砂规格模糊查询
     *
     * @return
     */
    @PostMapping("listMistedSandgrainsize")
    private AjaxResult listMistedSandgrainsize(@RequestBody SandFinenessDTO sandFinenessDTO) {

        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysSand> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysSand::getGrainSize, name);
        }

        List<SysSand> list = sysSandService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getGrainSize());
                    vo.setLabel(s.getGrainSize());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);


    }


    /**
     * 石颗粒级配下拉模糊
     *
     * @return
     */

    @PostMapping("listMistedStoneGrain")
    private AjaxResult listMistedStoneGrain(@RequestBody StoneGrainDTO stoneGrainDTO) {
        List<SysStoneGrain> sysStoneGrainList = sysSandFinenesService.listMistedStoneGrain(stoneGrainDTO);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = sysStoneGrainList.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 石颗粒尺寸下拉模糊查询
     *
     * @return
     */
    @PostMapping("listMistedStoneSize")
    private AjaxResult listMistedStoneSize(@RequestBody StoneGrainDTO stoneGrainDTO) {
        List<SysStoneSize> stoneSizeList = stoneSizeService.listMistedStoneSize(stoneGrainDTO);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = stoneSizeList.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 减水剂型号下拉模糊查询
     */
    @PostMapping("listWaterMistedReduce")
    private AjaxResult listWaterMistedReduce(@RequestBody StoneGrainDTO stoneGrainDTO) {
        List<SysWaterReducerType> waterReducerTypes = sysWaterReducerService.listWaterMistedReduce(stoneGrainDTO);

        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = waterReducerTypes.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);

    }


    /**
     * 粉煤灰型号的下拉模糊查询
     *
     * @return
     */
    @PostMapping("listMistedFlyashType")
    private AjaxResult listFlyashType(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();
        LambdaQueryWrapper<SysFlyash> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysFlyash::getGrade, name);
        }

        List<SysFlyash> list = sysFlyashService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getGrade());
                    vo.setLabel(s.getGrade());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);


    }


    /**
     * 粉煤灰出厂等级模糊查询
     *
     * @param sandFinenessDTO
     * @return
     */
    @PostMapping("listMistedFlyashfactoryGrade")
    private AjaxResult listMistedFlyashfactoryGrade(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();
        LambdaQueryWrapper<SysFlyash> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysFlyash::getFactoryGrade, name);
        }

        List<SysFlyash> list = sysFlyashService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getFactoryGrade());
                    vo.setLabel(s.getFactoryGrade());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);


    }


    /**
     * 矿粉型号模糊查询
     *
     * @param sandFinenessDTO
     * @return
     */
    @PostMapping("listMistedMineralModel")
    private AjaxResult listMistedMineralModel(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();
        LambdaQueryWrapper<SysMineralPowder> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysMineralPowder::getModel, name);
        }

        List<SysMineralPowder> list = sysMineralPowderService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getModel());
                    vo.setLabel(s.getModel());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);


    }


    /**
     * 矿粉等级模糊查询
     * slag_grade
     *
     * @return
     */
    @PostMapping("listMistedMineralSlagGrade")
    private AjaxResult listMistedMineralSlagGrade(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();
        LambdaQueryWrapper<SysMineralPowder> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysMineralPowder::getSlagGrade, name);
        }

        List<SysMineralPowder> list = sysMineralPowderService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getSlagGrade());
                    vo.setLabel(s.getSlagGrade());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);


    }


    /**
     * 其他掺合料型号模糊
     *
     * @return
     */
    @PostMapping("listMistedOtherAdmixturesModel")
    private AjaxResult listMistedOtherAdmixturesModel(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();
        LambdaQueryWrapper<SysOtherAdmixtures> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysOtherAdmixtures::getModel, name);
        }

        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = listOtherAdmixtures.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getModel());
                    vo.setLabel(s.getModel());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);


    }


    @GetMapping("listSandFineness")
    public AjaxResult listSandFineness() {
        // 获取原始数据
        List<SysSandFineness> listSandFinenesses = sysSandFinenesService.listSandFineness();

        // 转换成VO对象，并映射字段
        List<SandFinenessVO> sandFinenessVOList = listSandFinenesses.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 查询砂类型
     *
     * @return
     */

    @GetMapping("listSandType")
    private AjaxResult listSandType() {
        List<SysSandType> sandTypeList = sysSandTypeService.listSandType();
        // 转换成VO对象，并映射字段
        List<SandFinenessVO> sandFinenessVOList = sandTypeList.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        return AjaxResult.success(sandFinenessVOList);
    }

    /**
     * 石颗粒级配
     */
    @GetMapping("listStoneGrain")
    public AjaxResult listStoneGrain() {
        List<SysStoneGrain> sysStoneGrainList = sysStoneGrainService.listStoneGrain();

        List<SandFinenessVO> sysStoneGrainVOList = sysStoneGrainList.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());


        return AjaxResult.success(sysStoneGrainVOList);
    }


    /**
     * 查询石头颗粒尺寸
     */
    @GetMapping("listStoneSize")
    public AjaxResult listStoneSize() {
        List<SysStoneSize> stoneSizeList = stoneSizeService.listStoneSize();


        List<SandFinenessVO> sysStoneSizeVOList = stoneSizeList.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());
        return AjaxResult.success(sysStoneSizeVOList);
    }


    /**
     * 查询粉煤灰类型
     *
     * @return
     */
    @GetMapping("listflyashType")
    public AjaxResult listflyashType() {
        List<SysFlyashType> sysFlyashTypeList = sysFlyashTypeService.listflyashType();
        List<SandFinenessVO> sysFlyashTypeVOList = sysFlyashTypeList.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        return AjaxResult.success(sysFlyashTypeVOList);
    }

    /**
     * 查询粉煤灰细度
     */
    @GetMapping("listFlyashFinenes")
    public AjaxResult listFlyashFinenes() {
        List<SysFlyashFineness> sysFlyashFinenesses = sysFlyashFinenessService.listFlyashFinenes();

        List<SandFinenessVO> sysFlyashFinenessesVOList = sysFlyashFinenesses.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());
        return AjaxResult.success(sysFlyashFinenessesVOList);
    }


    /**
     * 查询减水剂类型
     *
     * @return
     */

    @GetMapping("listWaterReducerType")
    public AjaxResult listWaterReducerType() {
        List<SysWaterReducerType> listWaterReducerType = sysWaterReducerTypeService.listWaterReducerType();
        List<SandFinenessVO> sysFlyashFinenessesVOList = listWaterReducerType.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        return AjaxResult.success(sysFlyashFinenessesVOList);
    }


    /**
     * 查询耐久性能最大值最小值
     */

//    @GetMapping("/queryDurabilityPerformanceaxMin")
//    public AjaxResult queryDurabilityPerformanceaxMin() {
//        // 调用服务层获取数据
//        Map<String, Object> durabilityPerformanceMinAndMax = sysDurabilityPerformanceService.queryDurabilityPerformanceaxMin();
//
//        return AjaxResult.success(durabilityPerformanceMinAndMax);
//    }

    /**
     * 查询耐久性能表的最大值和最小值
     *
     * @return
     */
    @GetMapping("/queryDurabilityPerformancePullDown")
    public AjaxResult queryDurabilityPerformanceMinAndMax() {
        // 调用服务层获取数据
        Map<String, Object> durabilityMinAndMax = sysDurabilityPerformanceService.queryDurabilityPerformanceaxMin();

        // 构造符合需求的返回格式
        Map<String, Object> waterContent = new HashMap<>();
        waterContent.put("min", durabilityMinAndMax.get("minWaterContent"));
        waterContent.put("max", durabilityMinAndMax.get("maxWaterContent"));

        Map<String, Object> freezeResistanceLevel = new HashMap<>();
        freezeResistanceLevel.put("min", durabilityMinAndMax.get("minFreezeResistanceLevel"));
        freezeResistanceLevel.put("max", durabilityMinAndMax.get("maxFreezeResistanceLevel"));

        Map<String, Object> impermeabilityLevel = new HashMap<>();
        impermeabilityLevel.put("min", durabilityMinAndMax.get("minImpermeabilityLevel"));
        impermeabilityLevel.put("max", durabilityMinAndMax.get("maxImpermeabilityLevel"));

        Map<String, Object> carbonationDepth = new HashMap<>();
        carbonationDepth.put("min", durabilityMinAndMax.get("minCarbonationDepth"));
        carbonationDepth.put("max", durabilityMinAndMax.get("maxCarbonationDepth"));

        Map<String, Object> cementContent = new HashMap<>();
        cementContent.put("min", durabilityMinAndMax.get("minCementContent"));
        cementContent.put("max", durabilityMinAndMax.get("maxCementContent"));

        Map<String, Object> flyAshContent = new HashMap<>();
        flyAshContent.put("min", durabilityMinAndMax.get("minFlyAshContent"));
        flyAshContent.put("max", durabilityMinAndMax.get("maxFlyAshContent"));

        Map<String, Object> sandContent = new HashMap<>();
        sandContent.put("min", durabilityMinAndMax.get("minSandContent"));
        sandContent.put("max", durabilityMinAndMax.get("maxSandContent"));

        Map<String, Object> stoneContent = new HashMap<>();
        stoneContent.put("min", durabilityMinAndMax.get("minStoneContent"));
        stoneContent.put("max", durabilityMinAndMax.get("maxStoneContent"));

        Map<String, Object> waterReducerDosage = new HashMap<>();
        waterReducerDosage.put("min", durabilityMinAndMax.get("minWaterReducerDosage"));
        waterReducerDosage.put("max", durabilityMinAndMax.get("maxWaterReducerDosage"));

        Map<String, Object> efficiencyAgentDosage = new HashMap<>();
        efficiencyAgentDosage.put("min", durabilityMinAndMax.get("minEfficiencyAgentDosage"));
        efficiencyAgentDosage.put("max", durabilityMinAndMax.get("maxEfficiencyAgentDosage"));

        Map<String, Object> waterDosage = new HashMap<>();
        waterDosage.put("min", durabilityMinAndMax.get("minWaterDosage"));
        waterDosage.put("max", durabilityMinAndMax.get("maxWaterDosage"));

        Map<String, Object> powderDosage = new HashMap<>();
        powderDosage.put("min", durabilityMinAndMax.get("minPowderDosage"));
        powderDosage.put("max", durabilityMinAndMax.get("maxPowderDosage"));


        Map<String, Object> admixturesDosage = new HashMap<>();
        admixturesDosage.put("min", durabilityMinAndMax.get("minAdmixturesDosage"));
        admixturesDosage.put("max", durabilityMinAndMax.get("maxAdmixturesDosage"));



        Map<String, Object> swellingagentDosage = new HashMap<>();
        swellingagentDosage.put("min", durabilityMinAndMax.get("minSwellingagentDosage"));
        swellingagentDosage.put("max", durabilityMinAndMax.get("maxSwellingagentDosage"));


        Map<String, Object> sliderSection = new HashMap<>();
        sliderSection.put("waterContent", waterContent); // 水用量，单位为 kg/m³
        sliderSection.put("freezeResistanceLevel", freezeResistanceLevel); // 抗冻等级，表示材料耐受冻融循环的性能
        sliderSection.put("impermeabilityLevel", impermeabilityLevel); // 抗渗等级，表示材料抵抗水渗透能力的性能等级
        sliderSection.put("carbonationDepth", carbonationDepth); // 碳化深度，单位为 mm，用于衡量材料碳化程度
        sliderSection.put("cementContent", cementContent); // 水泥用量，单位为 kg/m³
        sliderSection.put("flyAshContent", flyAshContent); // 粉煤灰用量，单位为 kg/m³
        sliderSection.put("sandContent", sandContent); // 砂用量，单位为 kg/m³
        sliderSection.put("stoneContent", stoneContent); // 石料用量，单位为 kg/m³
        sliderSection.put("waterReducerDosage", waterReducerDosage); // 减水剂掺量，单位为百分比 (%)
        sliderSection.put("synergyDosage", efficiencyAgentDosage); // 增效剂掺量，单位为百分比 (%)


        sliderSection.put("waterDosage", waterDosage);//水掺量（%）
        sliderSection.put("powderDosage", powderDosage);///矿粉掺量
        sliderSection.put("admixturesDosage", admixturesDosage);//其他参合料掺量
        sliderSection.put("swellingagentDosage", swellingagentDosage);//膨胀剂掺量



        HashMap<Object, Object> idList = new HashMap<>();
// 获取ID列表并转换为所需格式
        Function<List<Integer>, List<Map<String, String>>> convertToValueLabelList = list ->
                list.stream()
                        .map(id -> {
                            Map<String, String> item = new HashMap<>();
                            item.put("value", String.valueOf(id));
                            item.put("label", String.valueOf(id));
                            return item;
                        })
                        .collect(Collectors.toList());


        List<Map<String, String>> regionIdList = convertToValueLabelList.apply(
                isysRegionService.listRegions().stream().map(SysRegion::getRegionId).collect(Collectors.toList())
        );

        List<Map<String, String>> cementIdList = convertToValueLabelList.apply(
                sysCementService.listCement().stream().map(SysCement::getCementId).collect(Collectors.toList())
        );

        List<Map<String, String>> sandIdList = convertToValueLabelList.apply(
                sysSandService.listSand().stream().map(SysSand::getSandId).collect(Collectors.toList())
        );

        List<Map<String, String>> stoneIdList = convertToValueLabelList.apply(
                sysStoneService.listStones().stream().map(SysStone::getStoneId).collect(Collectors.toList())
        );

        List<Map<String, String>> waterReducerList = convertToValueLabelList.apply(
                sysWaterReducerService.listWaterReduce().stream()
                        .map(reducer -> reducer.getReducerId().intValue())
                        .collect(Collectors.toList())
        );

        List<Map<String, String>> flyashIdList = convertToValueLabelList.apply(
                sysFlyashService.listFlyash().stream().map(SysFlyash::getFlyashId).collect(Collectors.toList())
        );


        List<Map<String, String>> efficiencyAgentIdList = convertToValueLabelList.apply(
                sysEfficiencyAgent.listefficiencyAgents().stream()
                        .map(agent -> agent.getAgentId().intValue())
                        .collect(Collectors.toList())
        );
        List<SysRegion> regionList = isysRegionService.listRegions();
        idList.put("regionIdList", regionIdList);
        idList.put("cementIdList", cementIdList);
        idList.put("sandIdList", sandIdList);
        idList.put("stoneIdList", stoneIdList);
        idList.put("waterReducerList", waterReducerList);
        idList.put("regionList", regionList);
        idList.put("flyashIdList", flyashIdList);
        idList.put("efficiencyAgentIdList", efficiencyAgentIdList);//增效剂掺量


/*        // 水泥
        List<SysCement> sysCementList = sysCementService.listCement();
        List<Map<String, Object>> cementIdListPlus = new ArrayList<>();
        for (SysCement sysCement : sysCementList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysCement.getModel());
            labelValueMap.put("value", sysCement.getCementId());
            cementIdListPlus.add(labelValueMap);
        }

        // 地区
        List<SysRegion> listRegion = isysRegionService.listRegions();
        List<Map<String, Object>> listRegionList = new ArrayList<>();
        for (SysRegion sysRegion : listRegion) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getRegionName());
            labelValueMap.put("value", sysRegion.getRegionId());

            listRegionList.add(labelValueMap);
        }


        List<SysSand> listSysSands = sysSandService.listSand();

        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        for (SysSand sysRegion : listSysSands) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getType());
            labelValueMap.put("value", sysRegion.getSandId());

            listSysSandLists.add(labelValueMap);
        }

        //石头
        List<SysStone> sysStoneList = sysStoneService.listStones();

        List<Map<String, Object>> listStoneList = new ArrayList<>();
        for (SysStone sysStone : sysStoneList) {
            Map<String, Object> labelStoneValueMaps = new HashMap<>();
            labelStoneValueMaps.put("label", sysStone.getParticleSizeDistribution());
            labelStoneValueMaps.put("value", sysStone.getStoneId());
            listStoneList.add(labelStoneValueMaps);
        }

        //减水剂
        List<SysWaterReducer> reducers = sysWaterReducerService.listWaterReduce();
        List<Map<String, Object>> listWaterList = new ArrayList<>();
        for (SysWaterReducer reducer : reducers) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", reducer.getModel());
            labelValueMap.put("value", reducer.getReducerId());
            listWaterList.add(labelValueMap);
        }

        List<SysFlyash> sysFlyashList = sysFlyashService.listFlyash();
        List<Map<String, Object>> listFlyashList = new ArrayList<>();
        for (SysFlyash sysFlyash : sysFlyashList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysFlyash.getGrade());
            labelValueMap.put("value", sysFlyash.getFlyashId());
            listFlyashList.add(labelValueMap);

        }


        List<SysEfficiencyAgent> efficiencyAgents = sysEfficiencyAgent.listefficiencyAgents();

        List<Map<String, Object>> efficiencyAgentList = new ArrayList<>();
        for (SysEfficiencyAgent efficiencyAgent : efficiencyAgents) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", efficiencyAgent.getModel());
            labelValueMap.put("value", efficiencyAgent.getId());
            efficiencyAgentList.add(labelValueMap);
        }


        // 水型号
        List<Map<String, Object>> waterModelList = new ArrayList<>();
        List<SysWater> listWaterModelList = waterService.list();
        for (SysWater sysWater : listWaterModelList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            waterModelList.add(labelValueMap);

        }
        //矿粉型号
        List<Map<String, Object>> mineralPowderList = new ArrayList<>();
        List<SysMineralPowder> listMineralPowderList = sysMineralPowderService.list();
        for (SysMineralPowder sysWater : listMineralPowderList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            mineralPowderList.add(labelValueMap);

        }

        //其他型号
        List<Map<String, Object>> otherAdmixturesList = new ArrayList<>();
        List<SysOtherAdmixtures> listOtherAdmixturesList = sysOtherAdmixturesService.list();
        for (SysOtherAdmixtures sysWater : listOtherAdmixturesList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            waterModelList.add(labelValueMap);

        }

        //膨胀剂型号
        List<Map<String, Object>> swellingagentList = new ArrayList<>();
        List<SysSwellingagent> listSwellingagentList = sysSwellingagentService.list();
        for (SysSwellingagent sysWater : listSwellingagentList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            swellingagentList.add(labelValueMap);

        }*/



// 水泥
        List<SysCement> sysCementList = sysCementService.listCement();
        List<Map<String, Object>> cementIdListPlus = new ArrayList<>();
        Set<String> cementSet = new HashSet<>();
        for (SysCement sysCement : sysCementList) {
            String model = sysCement.getModel();
            if (cementSet.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", sysCement.getCementId());
                cementIdListPlus.add(labelValueMap);
            }
        }

// 地区 - 保留原逻辑
        List<SysRegion> listRegion = isysRegionService.listRegions();
        List<Map<String, Object>> listRegionList = new ArrayList<>();
        for (SysRegion sysRegion : listRegion) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getRegionId());
            labelValueMap.put("value", sysRegion.getRegionName());
            listRegionList.add(labelValueMap);
        }


// 砂类型
        List<SysSand> listSysSands = sysSandService.listSand();
        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        Set<String> sandSet = new HashSet<>();
        for (SysSand sysSand : listSysSands) {
            String type = sysSand.getType();
            if (sandSet.add(type)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", type);
                labelValueMap.put("value", sysSand.getSandId());
                listSysSandLists.add(labelValueMap);
            }
        }

        // 石头
        List<SysStone> sysStoneList = sysStoneService.listStones();
        List<Map<String, Object>> listStoneList = new ArrayList<>();
        Set<String> stoneSet = new HashSet<>();
        for (SysStone sysStone : sysStoneList) {
            String distribution = sysStone.getParticleSizeDistribution();
            if (stoneSet.add(distribution)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", distribution);
                labelValueMap.put("value", sysStone.getStoneId());
                listStoneList.add(labelValueMap);
            }
        }

       // 减水剂
        List<SysWaterReducer> reducers = sysWaterReducerService.listWaterReduce();
        List<Map<String, Object>> listWaterList = new ArrayList<>();
        Set<String> reducerSet = new HashSet<>();
        for (SysWaterReducer reducer : reducers) {
            String model = reducer.getModel();
            if (reducerSet.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", reducer.getReducerId());
                listWaterList.add(labelValueMap);
            }
        }

        // 粉煤灰
        List<SysFlyash> sysFlyashList = sysFlyashService.listFlyash();
        List<Map<String, Object>> listFlyashList = new ArrayList<>();
        Set<String> flyashSet = new HashSet<>();
        for (SysFlyash sysFlyash : sysFlyashList) {
            String grade = sysFlyash.getGrade();
            if (flyashSet.add(grade)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", grade);
                labelValueMap.put("value", sysFlyash.getFlyashId());
                listFlyashList.add(labelValueMap);
            }
        }

        // 高效剂
        List<SysEfficiencyAgent> efficiencyAgents = sysEfficiencyAgent.listefficiencyAgents();
        List<Map<String, Object>> efficiencyAgentList = new ArrayList<>();
        Set<String> efficiencySet = new HashSet<>();
        for (SysEfficiencyAgent efficiencyAgent : efficiencyAgents) {
            String model = efficiencyAgent.getModel();
            if (efficiencySet.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", efficiencyAgent.getId());
                efficiencyAgentList.add(labelValueMap);
            }
        }

          // 水型号
        List<SysWater> listWaterModelList = waterService.list();
        List<Map<String, Object>> waterModelList = new ArrayList<>();
        Set<String> waterSet = new HashSet<>();
        for (SysWater sysWater : listWaterModelList) {
            String model = sysWater.getModel();
            if (waterSet.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                waterModelList.add(labelValueMap);
            }
        }

// 矿粉型号
        List<SysMineralPowder> listMineralPowderList = sysMineralPowderService.list();
        List<Map<String, Object>> mineralPowderList = new ArrayList<>();
        Set<String> mineralPowderSet = new HashSet<>();
        for (SysMineralPowder sysMineralPowder : listMineralPowderList) {
            String model = sysMineralPowder.getModel();
            if (mineralPowderSet.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                mineralPowderList.add(labelValueMap);
            }
        }

// 其他型号
        List<SysOtherAdmixtures> listOtherAdmixturesList = sysOtherAdmixturesService.list();
        List<Map<String, Object>> otherAdmixturesList = new ArrayList<>();
        Set<String> admixturesSet = new HashSet<>();
        for (SysOtherAdmixtures sysOtherAdmixtures : listOtherAdmixturesList) {
            String model = sysOtherAdmixtures.getModel();
            if (admixturesSet.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                otherAdmixturesList.add(labelValueMap);
            }
        }

// 膨胀剂型号
        List<SysSwellingagent> listSwellingagentList = sysSwellingagentService.list();
        List<Map<String, Object>> swellingagentList = new ArrayList<>();
        Set<String> swellingagentSet = new HashSet<>();
        for (SysSwellingagent sysSwellingagent : listSwellingagentList) {
            String model = sysSwellingagent.getModel();
            if (swellingagentSet.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                swellingagentList.add(labelValueMap);
            }
        }




        // 创建 idsPlus 并填充数据
        Map<String, Object> idListPlus = new HashMap<>();
        idListPlus.put("regionIdList", listRegionList);
        idListPlus.put("cementIdList", cementIdListPlus);
        idListPlus.put("sandIdList", listSysSandLists);
        idListPlus.put("stoneIdList", listStoneList);
        idListPlus.put("waterReducerList", listWaterList);
        idListPlus.put("flyashIdList", listFlyashList);
        idListPlus.put("efficiencyAgentIdList", efficiencyAgentList);
        idListPlus.put("regionList", "");



        idListPlus.put("waterModel", waterModelList);//水
        idListPlus.put("mineralModel",mineralPowderList );//矿粉
        idListPlus.put("otherAdmixturesModel", otherAdmixturesList);//其他型号
        idListPlus.put("swellingagentModel",swellingagentList );//    //其他型号



        Map<String, Object> result = new HashMap<>();
        result.put("sliderSection", sliderSection);
        //result.put("ids", idList);
        result.put("ids", idListPlus);
        // 返回 AjaxResult
        return AjaxResult.success(result);
    }


    /**
     * 查询水泥表的最大值和最小值
     *
     * @return
     */
    @GetMapping("/queryCementMinAndMax")
    public AjaxResult queryCementMinAndMax() {
        // 调用服务层获取数据
        Map<String, Object> cementMinAndMax = sysCementService.getCementMinAndMax();
        // 构造符合需求的返回格式
        Map<String, Object> cementCaO = new HashMap<>();
        cementCaO.put("min", cementMinAndMax.get("minCaocontent"));
        cementCaO.put("max", cementMinAndMax.get("maxCaocontent"));
        Map<String, Object> cementSiO2 = new HashMap<>();
        cementSiO2.put("min", cementMinAndMax.get("minSio2content"));
        cementSiO2.put("max", cementMinAndMax.get("maxSio2content"));
        Map<String, Object> cementAl2O3 = new HashMap<>();
        cementAl2O3.put("min", cementMinAndMax.get("minAl2o3content"));
        cementAl2O3.put("max", cementMinAndMax.get("maxAl2o3content"));
        Map<String, Object> sliderSection = new HashMap<>();
        sliderSection.put("cementCaO", cementCaO);
        sliderSection.put("cementSiO2", cementSiO2);
        sliderSection.put("cementAl2O3", cementAl2O3);
        Map<String, Object> result = new HashMap<>();
        result.put("sliderSection", sliderSection);
        // 返回 AjaxResult
        return AjaxResult.success(result);
    }


    /**
     * 查询石头表的最大值最小值
     */
    @GetMapping("/queryStoneMinAndMax")
    public ResponseEntity<Map<String, Object>> queryStoneMinAndMax() {
        // 从服务层获取数据
        Map<String, Object> stoneMinAndMax = sysStoneService.getStoneMinAndMax();

        // 封装 cementCaO 数据
        Map<String, Object> stoneDensity = new HashMap<>();
        stoneDensity.put("min", stoneMinAndMax.get("minBulkdensity"));
        stoneDensity.put("max", stoneMinAndMax.get("maxBulkdensity"));
        // 返回整体结果
        Map<String, Object> result = new HashMap<>();
        result.put("stoneDensity", stoneDensity);

        return ResponseEntity.ok(result);
    }


    /**
     * 查询减水剂的最大值最小值
     */
    @GetMapping("querywaterReducerMinAndMax")
    public AjaxResult querywaterReducerMinAndMax() {
        // 调用 service 获取最大值最小值
        Map<String, Object> waterReducerMinAndMax = sysWaterReducerService.getwaterReducerAndMax();

        // 构建符合要求的返回格式
        Map<String, Object> solidContent = new HashMap<>();
        solidContent.put("min", waterReducerMinAndMax.get("minSolidContent"));
        solidContent.put("max", waterReducerMinAndMax.get("maxSolidContent"));

        Map<String, Object> reducingRate = new HashMap<>();
        reducingRate.put("min", waterReducerMinAndMax.get("minReducingRate"));
        reducingRate.put("max", waterReducerMinAndMax.get("maxReducingRate"));

        // 封装 sliderSection 对象
        Map<String, Object> sliderSection = new HashMap<>();
        sliderSection.put("solidContent", solidContent);
        sliderSection.put("reducingRate", reducingRate);

        // 返回结果
        return AjaxResult.success(sliderSection);
    }

    /**
     * 查询粉煤灰表的最大值最小值
     */

    @GetMapping("/queryFlyashMaxMin")
    public AjaxResult queryFlyashMaxMin() {
        // 调用 service 获取最大值和最小值
        Map<String, Object> flyashMinAndMax = sysFlyashService.queryFlyashMaxMin();
        // 构建符合要求的返回格式
        Map<String, Object> fineness = new HashMap<>();
        fineness.put("min", flyashMinAndMax.get("minFineness"));
        fineness.put("max", flyashMinAndMax.get("maxFineness"));
        // 封装到最终返回的 Map
        Map<String, Object> result = new HashMap<>();
        result.put("fineness", fineness);
        // 返回结果
        return AjaxResult.success(result);
    }


    /**
     * 查询力学性能的最大值最小值
     */
    @GetMapping("queryMechanicalPerformanceMaxMin")
    public AjaxResult queryMechanicalPerformanceMaxMin() {
        // 获取从数据库中查询到的最大值和最小值
        Map<String, Object> efficiencyMerchantMinAndMax = sysEfficiencyMerchantNameService.queryMechanicalPerformanceMaxMin();

        // 构建每个字段的最小值和最大值
        Map<String, Object> compressiveStrength7d = new HashMap<>();
        compressiveStrength7d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength7d"));
        compressiveStrength7d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength7d"));

        Map<String, Object> compressiveStrength28d = new HashMap<>();
        compressiveStrength28d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength28d"));
        compressiveStrength28d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength28d"));

        Map<String, Object> waterContent = new HashMap<>();
        waterContent.put("min", efficiencyMerchantMinAndMax.get("minWaterContent"));
        waterContent.put("max", efficiencyMerchantMinAndMax.get("maxWaterContent"));

        Map<String, Object> cementContent = new HashMap<>();
        cementContent.put("min", efficiencyMerchantMinAndMax.get("minCementContent"));
        cementContent.put("max", efficiencyMerchantMinAndMax.get("maxCementContent"));

        Map<String, Object> flyAshContent = new HashMap<>();
        flyAshContent.put("min", efficiencyMerchantMinAndMax.get("minFlyAshContent"));
        flyAshContent.put("max", efficiencyMerchantMinAndMax.get("maxFlyAshContent"));

        Map<String, Object> sandContent = new HashMap<>();
        sandContent.put("min", efficiencyMerchantMinAndMax.get("minSandContent"));
        sandContent.put("max", efficiencyMerchantMinAndMax.get("maxSandContent"));

        Map<String, Object> stoneContent = new HashMap<>();
        stoneContent.put("min", efficiencyMerchantMinAndMax.get("minStoneContent"));
        stoneContent.put("max", efficiencyMerchantMinAndMax.get("maxStoneContent"));

        Map<String, Object> waterReducerDosage = new HashMap<>();
        waterReducerDosage.put("min", efficiencyMerchantMinAndMax.get("minWaterReducerDosage"));
        waterReducerDosage.put("max", efficiencyMerchantMinAndMax.get("maxWaterReducerDosage"));

        Map<String, Object> efficiencyAgentDosage = new HashMap<>();
        efficiencyAgentDosage.put("min", efficiencyMerchantMinAndMax.get("minEfficiencyAgentDosage"));
        efficiencyAgentDosage.put("max", efficiencyMerchantMinAndMax.get("maxEfficiencyAgentDosage"));


        // 将所有的结果封装到最终的返回 Map 中
        Map<String, Object> result = new HashMap<>();
        result.put("compressiveStrength7d", compressiveStrength7d);
        result.put("compressiveStrength28d", compressiveStrength28d);

        result.put("waterContent", waterContent);
        result.put("cementContent", cementContent);
        result.put("flyAshContent", flyAshContent);
        result.put("sandContent", sandContent);
        result.put("stoneContent", stoneContent);
        result.put("waterReducerDosage", waterReducerDosage);
        result.put("synergyDosage", efficiencyAgentDosage);

        // 返回结果
        return AjaxResult.success(result);
    }


    /**
     * 查询变形性能的最大值最小值
     */
    @GetMapping("querylistDeformationMaxMin")
    public AjaxResult querylistDeformationMaxMin() {
        // 获取从数据库中查询到的最大值和最小值
        Map<String, Object> deformationPerformanceMinAndMax = sysDeformationPerformanceService.queryDeformationPerformanceMaxMin();

        // 构建每个字段的最小值和最大值
        Map<String, Object> shrinkage7d = new HashMap<>();
        shrinkage7d.put("min", deformationPerformanceMinAndMax.get("minShrinkage7d"));
        shrinkage7d.put("max", deformationPerformanceMinAndMax.get("maxShrinkage7d"));

        Map<String, Object> shrinkage28d = new HashMap<>();
        shrinkage28d.put("min", deformationPerformanceMinAndMax.get("minShrinkage28d"));
        shrinkage28d.put("max", deformationPerformanceMinAndMax.get("maxShrinkage28d"));

        Map<String, Object> waterContent = new HashMap<>();
        waterContent.put("min", deformationPerformanceMinAndMax.get("minWaterContent"));
        waterContent.put("max", deformationPerformanceMinAndMax.get("maxWaterContent"));

        Map<String, Object> cementContent = new HashMap<>();
        cementContent.put("min", deformationPerformanceMinAndMax.get("minCementContent"));
        cementContent.put("max", deformationPerformanceMinAndMax.get("maxCementContent"));

        Map<String, Object> flyAshContent = new HashMap<>();
        flyAshContent.put("min", deformationPerformanceMinAndMax.get("minFlyAshContent"));
        flyAshContent.put("max", deformationPerformanceMinAndMax.get("maxFlyAshContent"));

        Map<String, Object> sandContent = new HashMap<>();
        sandContent.put("min", deformationPerformanceMinAndMax.get("minSandContent"));
        sandContent.put("max", deformationPerformanceMinAndMax.get("maxSandContent"));

        Map<String, Object> stoneContent = new HashMap<>();
        stoneContent.put("min", deformationPerformanceMinAndMax.get("minStoneContent"));
        stoneContent.put("max", deformationPerformanceMinAndMax.get("maxStoneContent"));

        Map<String, Object> waterReducerDosage = new HashMap<>();
        waterReducerDosage.put("min", deformationPerformanceMinAndMax.get("minWaterReducerDosage"));
        waterReducerDosage.put("max", deformationPerformanceMinAndMax.get("maxWaterReducerDosage"));

        // 将所有的结果封装到最终的返回 Map 中
        Map<String, Object> result = new HashMap<>();
        result.put("shrinkage7d", shrinkage7d);
        result.put("shrinkage28d", shrinkage28d);
        result.put("waterContent", waterContent);
        result.put("cementContent", cementContent);
        result.put("flyAshContent", flyAshContent);
        result.put("sandContent", sandContent);
        result.put("stoneContent", stoneContent);
        result.put("waterReducerDosage", waterReducerDosage);

        // 返回结果
        return AjaxResult.success(result);
    }


    /**
     * 查询耐久性能最大值最小值
     */
//    @GetMapping("querylistDurabilityPerformanceMaxMin")
//    public AjaxResult querylistDurabilityPerformanceMaxMin() {
//
//        sysEfficiencyMerchantNameService.querylistDurabilityPerformanceMaxMin();
//
//    }


    /**
     * 查询变形性能下拉框信息
     */
    @GetMapping("listDeformationPullDown")
    public AjaxResult listDeformationPullDown() {

        Map<String, Object> deformationPerformanceMinAndMax = sysDeformationPerformanceService.queryDeformationPerformanceMaxMin();

        // 构建每个字段的最小值和最大值
        Map<String, Object> shrinkage7d = new HashMap<>();
        shrinkage7d.put("min", deformationPerformanceMinAndMax.get("minShrinkage7d"));
        shrinkage7d.put("max", deformationPerformanceMinAndMax.get("maxShrinkage7d"));

        Map<String, Object> shrinkage28d = new HashMap<>();
        shrinkage28d.put("min", deformationPerformanceMinAndMax.get("minShrinkage28d"));
        shrinkage28d.put("max", deformationPerformanceMinAndMax.get("maxShrinkage28d"));

        Map<String, Object> waterContent = new HashMap<>();
        waterContent.put("min", deformationPerformanceMinAndMax.get("minWaterContent"));
        waterContent.put("max", deformationPerformanceMinAndMax.get("maxWaterContent"));

        Map<String, Object> cementContent = new HashMap<>();
        cementContent.put("min", deformationPerformanceMinAndMax.get("minCementContent"));
        cementContent.put("max", deformationPerformanceMinAndMax.get("maxCementContent"));

        Map<String, Object> flyAshContent = new HashMap<>();
        flyAshContent.put("min", deformationPerformanceMinAndMax.get("minFlyAshContent"));
        flyAshContent.put("max", deformationPerformanceMinAndMax.get("maxFlyAshContent"));

        Map<String, Object> sandContent = new HashMap<>();
        sandContent.put("min", deformationPerformanceMinAndMax.get("minSandContent"));
        sandContent.put("max", deformationPerformanceMinAndMax.get("maxSandContent"));

        Map<String, Object> stoneContent = new HashMap<>();
        stoneContent.put("min", deformationPerformanceMinAndMax.get("minStoneContent"));
        stoneContent.put("max", deformationPerformanceMinAndMax.get("maxStoneContent"));

        Map<String, Object> waterReducerDosage = new HashMap<>();
        waterReducerDosage.put("min", deformationPerformanceMinAndMax.get("minWaterReducerDosage"));
        waterReducerDosage.put("max", deformationPerformanceMinAndMax.get("maxWaterReducerDosage"));

        Map<String, Object> efficiencyAgentDosage = new HashMap<>();
        efficiencyAgentDosage.put("min", deformationPerformanceMinAndMax.get("minEfficiencyAgentDosage"));
        efficiencyAgentDosage.put("max", deformationPerformanceMinAndMax.get("maxEfficiencyAgentDosage"));




        Map<String, Object> waterDosage = new HashMap<>();
        waterDosage.put("min", deformationPerformanceMinAndMax.get("minWaterDosage"));
        waterDosage.put("max", deformationPerformanceMinAndMax.get("maxWaterDosage"));

        Map<String, Object> powderDosage = new HashMap<>();
        powderDosage.put("min", deformationPerformanceMinAndMax.get("minPowderDosage"));
        powderDosage.put("max", deformationPerformanceMinAndMax.get("maxPowderDosage"));


        Map<String, Object> admixturesDosage = new HashMap<>();
        admixturesDosage.put("min", deformationPerformanceMinAndMax.get("minAdmixturesDosage"));
        admixturesDosage.put("max", deformationPerformanceMinAndMax.get("maxAdmixturesDosage"));



        Map<String, Object> swellingagentDosage = new HashMap<>();
        swellingagentDosage.put("min", deformationPerformanceMinAndMax.get("minSwellingagentDosage"));
        swellingagentDosage.put("max", deformationPerformanceMinAndMax.get("maxSwellingagentDosage"));


        // 将所有的结果封装到最终的返回 Map 中
        Map<String, Object> sliderSection = new HashMap<>();
        sliderSection.put("shrinkage7d", shrinkage7d);
        sliderSection.put("shrinkage28d", shrinkage28d);
        sliderSection.put("waterContent", waterContent);
        sliderSection.put("cementContent", cementContent);
        sliderSection.put("flyAshContent", flyAshContent);
        sliderSection.put("sandContent", sandContent);
        sliderSection.put("stoneContent", stoneContent);
        sliderSection.put("waterReducerDosage", waterReducerDosage);
        sliderSection.put("synergyDosage", efficiencyAgentDosage);

        sliderSection.put("waterDosage", waterDosage);//水掺量（%）
        sliderSection.put("powderDosage", powderDosage);///矿粉掺量
        sliderSection.put("admixturesDosage", admixturesDosage);//其他参合料掺量
        sliderSection.put("swellingagentDosage", swellingagentDosage);//膨胀剂掺量



        // 获取ID列表并转换为所需格式
        Function<List<Integer>, List<Map<String, String>>> convertToValueLabelList = list ->
                list.stream()
                        .map(id -> {
                            Map<String, String> item = new HashMap<>();
                            item.put("value", String.valueOf(id));
                            item.put("label", String.valueOf(id));
                            return item;
                        })
                        .collect(Collectors.toList());


        List<Map<String, String>> regionIdList = convertToValueLabelList.apply(
                isysRegionService.listRegions().stream().map(SysRegion::getRegionId).collect(Collectors.toList())
        );

        List<Map<String, String>> cementIdList = convertToValueLabelList.apply(
                sysCementService.listCement().stream().map(SysCement::getCementId).collect(Collectors.toList())
        );

        List<Map<String, String>> sandIdList = convertToValueLabelList.apply(
                sysSandService.listSand().stream().map(SysSand::getSandId).collect(Collectors.toList())
        );

        List<Map<String, String>> stoneIdList = convertToValueLabelList.apply(
                sysStoneService.listStones().stream().map(SysStone::getStoneId).collect(Collectors.toList())
        );

        List<Map<String, String>> waterReducerList = convertToValueLabelList.apply(
                sysWaterReducerService.listWaterReduce().stream()
                        .map(reducer -> reducer.getReducerId().intValue())
                        .collect(Collectors.toList())
        );

        List<Map<String, String>> flyashIdList = convertToValueLabelList.apply(
                sysFlyashService.listFlyash().stream().map(SysFlyash::getFlyashId).collect(Collectors.toList())
        );


        List<Map<String, String>> efficiencyAgentIdList = convertToValueLabelList.apply(
                sysEfficiencyAgent.listefficiencyAgents().stream()
                        .map(agent -> agent.getAgentId().intValue())
                        .collect(Collectors.toList())
        );


        List<SysRegion> regionList = isysRegionService.listRegions();
        Map<String, Object> idList = new HashMap<>();
        idList.put("regionList", regionList);

        idList.put("regionIdList", regionIdList);
        idList.put("cementIdList", cementIdList);
        idList.put("sandIdList", sandIdList);
        idList.put("stoneIdList", stoneIdList);
        idList.put("waterReducerList", waterReducerList);
        idList.put("regionList", regionList);
        idList.put("flyashIdList", flyashIdList);
        idList.put("efficiencyAgentIdList", efficiencyAgentIdList);//增效剂掺量

/*
        // 水泥
        List<SysCement> sysCementList = sysCementService.listCement();
        List<Map<String, Object>> cementIdListPlus = new ArrayList<>();
        for (SysCement sysCement : sysCementList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysCement.getModel());
            labelValueMap.put("value", sysCement.getModel());
            cementIdListPlus.add(labelValueMap);
        }

        // 地区
        List<SysRegion> listRegion = isysRegionService.listRegions();
        List<Map<String, Object>> listRegionList = new ArrayList<>();
        for (SysRegion sysRegion : listRegion) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getRegionName());
            labelValueMap.put("value", sysRegion.getRegionName());

            listRegionList.add(labelValueMap);
        }


        List<SysSand> listSysSands = sysSandService.listSand();

        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        for (SysSand sysRegion : listSysSands) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getType());
            labelValueMap.put("value",  sysRegion.getType());

            listSysSandLists.add(labelValueMap);
        }

        //石头
        List<SysStone> sysStoneList = sysStoneService.listStones();

        List<Map<String, Object>> listStoneList = new ArrayList<>();
        for (SysStone sysStone : sysStoneList) {
            Map<String, Object> labelStoneValueMaps = new HashMap<>();
            labelStoneValueMaps.put("label", sysStone.getParticleSizeDistribution());
            labelStoneValueMaps.put("value", sysStone.getParticleSizeDistribution());
            listStoneList.add(labelStoneValueMaps);
        }

        //减水剂
        List<SysWaterReducer> reducers = sysWaterReducerService.listWaterReduce();
        List<Map<String, Object>> listWaterList = new ArrayList<>();
        for (SysWaterReducer reducer : reducers) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", reducer.getModel());
            labelValueMap.put("value", reducer.getModel());
            listWaterList.add(labelValueMap);
        }

        List<SysFlyash> sysFlyashList = sysFlyashService.listFlyash();
        List<Map<String, Object>> listFlyashList = new ArrayList<>();
        for (SysFlyash sysFlyash : sysFlyashList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysFlyash.getGrade());
            labelValueMap.put("value", sysFlyash.getGrade());
            listFlyashList.add(labelValueMap);

        }


        List<SysEfficiencyAgent> efficiencyAgents = sysEfficiencyAgent.listefficiencyAgents();

        List<Map<String, Object>> efficiencyAgentList = new ArrayList<>();
        for (SysEfficiencyAgent efficiencyAgent : efficiencyAgents) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", efficiencyAgent.getModel());
            labelValueMap.put("value", efficiencyAgent.getModel());
            efficiencyAgentList.add(labelValueMap);
        }





        // 水型号
        List<Map<String, Object>> waterModelList = new ArrayList<>();
        List<SysWater> listWaterModelList = waterService.list();
        for (SysWater sysWater : listWaterModelList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            waterModelList.add(labelValueMap);

        }




        //矿粉型号
        List<Map<String, Object>> mineralPowderList = new ArrayList<>();
        List<SysMineralPowder> listMineralPowderList = sysMineralPowderService.list();
        for (SysMineralPowder sysWater : listMineralPowderList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            mineralPowderList.add(labelValueMap);

        }

        //其他型号
        List<Map<String, Object>> otherAdmixturesList = new ArrayList<>();
        List<SysOtherAdmixtures> listOtherAdmixturesList = sysOtherAdmixturesService.list();
        for (SysOtherAdmixtures sysWater : listOtherAdmixturesList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            waterModelList.add(labelValueMap);

        }

        //膨胀剂型号
        List<Map<String, Object>> swellingagentList = new ArrayList<>();
        List<SysSwellingagent> listSwellingagentList = sysSwellingagentService.list();
        for (SysSwellingagent sysWater : listSwellingagentList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            swellingagentList.add(labelValueMap);

        }*/



// 水泥
        List<SysCement> sysCementList = sysCementService.listCement();
        List<Map<String, Object>> cementIdListPlus = new ArrayList<>();
        Set<String> cementModels = new HashSet<>();
        for (SysCement sysCement : sysCementList) {
            String model = sysCement.getModel();
            if (cementModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                cementIdListPlus.add(labelValueMap);
            }
        }

// 地区

        List<SysRegion> listRegion = isysRegionService.listRegions();
        List<Map<String, Object>> listRegionList = new ArrayList<>();
        for (SysRegion sysRegion : listRegion) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getRegionId());
            labelValueMap.put("value", sysRegion.getRegionName());
            listRegionList.add(labelValueMap);
        }

// 砂类型
        List<SysSand> listSysSands = sysSandService.listSand();
        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        Set<String> sandTypes = new HashSet<>();
        for (SysSand sysSand : listSysSands) {
            String type = sysSand.getType();
            if (sandTypes.add(type)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", type);
                labelValueMap.put("value", type);
                listSysSandLists.add(labelValueMap);
            }
        }

// 石头类型
        List<SysStone> sysStoneList = sysStoneService.listStones();
        List<Map<String, Object>> listStoneList = new ArrayList<>();
        Set<String> stoneDistributions = new HashSet<>();
        for (SysStone sysStone : sysStoneList) {
            String distribution = sysStone.getParticleSizeDistribution();
            if (stoneDistributions.add(distribution)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", distribution);
                labelValueMap.put("value", distribution);
                listStoneList.add(labelValueMap);
            }
        }

// 减水剂
        List<SysWaterReducer> reducers = sysWaterReducerService.listWaterReduce();
        List<Map<String, Object>> listWaterList = new ArrayList<>();
        Set<String> waterReducerModels = new HashSet<>();
        for (SysWaterReducer reducer : reducers) {
            String model = reducer.getModel();
            if (waterReducerModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                listWaterList.add(labelValueMap);
            }
        }

// 粉煤灰
        List<SysFlyash> sysFlyashList = sysFlyashService.listFlyash();
        List<Map<String, Object>> listFlyashList = new ArrayList<>();
        Set<String> flyashGrades = new HashSet<>();
        for (SysFlyash sysFlyash : sysFlyashList) {
            String grade = sysFlyash.getGrade();
            if (flyashGrades.add(grade)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", grade);
                labelValueMap.put("value", grade);
                listFlyashList.add(labelValueMap);
            }
        }

// 高效剂
        List<SysEfficiencyAgent> efficiencyAgents = sysEfficiencyAgent.listefficiencyAgents();
        List<Map<String, Object>> efficiencyAgentList = new ArrayList<>();
        Set<String> efficiencyAgentModels = new HashSet<>();
        for (SysEfficiencyAgent efficiencyAgent : efficiencyAgents) {
            String model = efficiencyAgent.getModel();
            if (efficiencyAgentModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                efficiencyAgentList.add(labelValueMap);
            }
        }

// 水型号
        List<SysWater> listWaterModelList = waterService.list();
        List<Map<String, Object>> waterModelList = new ArrayList<>();
        Set<String> waterModels = new HashSet<>();
        for (SysWater sysWater : listWaterModelList) {
            String model = sysWater.getModel();
            if (waterModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                waterModelList.add(labelValueMap);
            }
        }

// 矿粉型号
        List<SysMineralPowder> listMineralPowderList = sysMineralPowderService.list();
        List<Map<String, Object>> mineralPowderList = new ArrayList<>();
        Set<String> mineralPowderModels = new HashSet<>();
        for (SysMineralPowder sysMineralPowder : listMineralPowderList) {
            String model = sysMineralPowder.getModel();
            if (mineralPowderModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                mineralPowderList.add(labelValueMap);
            }
        }

// 其他型号
        List<SysOtherAdmixtures> listOtherAdmixturesList = sysOtherAdmixturesService.list();
        List<Map<String, Object>> otherAdmixturesList = new ArrayList<>();
        Set<String> otherAdmixtureModels = new HashSet<>();
        for (SysOtherAdmixtures sysOtherAdmixtures : listOtherAdmixturesList) {
            String model = sysOtherAdmixtures.getModel();
            if (otherAdmixtureModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                otherAdmixturesList.add(labelValueMap);
            }
        }

// 膨胀剂型号
        List<SysSwellingagent> listSwellingagentList = sysSwellingagentService.list();
        List<Map<String, Object>> swellingagentList = new ArrayList<>();
        Set<String> swellingagentModels = new HashSet<>();
        for (SysSwellingagent sysSwellingagent : listSwellingagentList) {
            String model = sysSwellingagent.getModel();
            if (swellingagentModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                swellingagentList.add(labelValueMap);
            }
        }


        // 创建 idsPlus 并填充数据
        Map<String, Object> idListPlus = new HashMap<>();
        idListPlus.put("regionIdList", listRegionList);
        idListPlus.put("cementIdList", cementIdListPlus);
        idListPlus.put("sandIdList", listSysSandLists);
        idListPlus.put("stoneIdList", listStoneList);
        idListPlus.put("waterReducerList", listWaterList);
        idListPlus.put("flyashIdList", listFlyashList);
        idListPlus.put("efficiencyAgentIdList", efficiencyAgentList);
        idListPlus.put("regionList", "");



        idListPlus.put("waterModel", waterModelList);//水
        idListPlus.put("mineralModel",mineralPowderList );//矿粉
        idListPlus.put("otherAdmixturesModel", otherAdmixturesList);//其他型号
        idListPlus.put("swellingagentModel",swellingagentList );//    //其他型号




        Map<String, Object> result = new HashMap<>();
        // result.put("ids", idList);
        result.put("ids", idListPlus);

        result.put("sliderSection", sliderSection);

        return AjaxResult.success(result);
    }


    /**
     * 查询原材料下拉框信息
     *
     * @return
     */
    @GetMapping("/listPullDown")
    public AjaxResult listPullDown() {
//        List<SysSandFineness> listSandFinenesses = sysSandFinenesService.listSandFineness();
//        // 转换成VO对象，并映射字段
//        List<SandFinenessVO> sandFinenessVOList = listSandFinenesses.stream()
//                .map(s -> {
//                    SandFinenessVO vo = new SandFinenessVO();
//                    vo.setValue(s.getName());
//                    vo.setLabel(s.getName());
//                    return vo;
//                })
//                .collect(Collectors.toList());


        List<SysSandType> sandTypeList = sysSandTypeService.listSandType();
        // 转换成VO对象，并映射字段
        List<SandFinenessVO> sandTypeVOList = sandTypeList.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());


        List<SysStoneGrain> sysStoneGrainList = sysStoneGrainService.listStoneGrain();
        List<SandFinenessVO> sysStoneGrainVOList = sysStoneGrainList.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());


//        List<SysFlyashType> sysFlyashTypeList = sysFlyashTypeService.listflyashType();
//        List<SandFinenessVO> sysFlyashTypeVOList = sysFlyashTypeList.stream()
//                .map(s -> {
//                    SandFinenessVO vo = new SandFinenessVO();
//                    vo.setValue(s.getName());
//                    vo.setLabel(s.getName());
//                    return vo;
//                })
//                .collect(Collectors.toList());


//        List<SysFlyashFineness> sysFlyashFinenesses = sysFlyashFinenessService.listFlyashFinenes();
//        List<SandFinenessVO> sysFlyashFinenessesVOList = sysFlyashFinenesses.stream()
//                .map(s -> {
//                    SandFinenessVO vo = new SandFinenessVO();
//                    vo.setValue(s.getName());
//                    vo.setLabel(s.getName());
//                    return vo;
//                })
//                .collect(Collectors.toList());


        List<SysWaterReducerType> listWaterReducerType = sysWaterReducerTypeService.listWaterReducerType();
        List<SandFinenessVO> listWaterReducerVOList = listWaterReducerType.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());


        List<SysStoneSize> stoneSizeList = stoneSizeService.listStoneSize();
        List<SandFinenessVO> sysStoneSizeVOList = stoneSizeList.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());


        // 获取水表 类型名称
        List<SysWaterModel> sysWaterModellist = sysWaterModelService.list();
        List<SandFinenessVO> sysWaterModelList = sysWaterModellist.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getModelName());
                    vo.setLabel(s.getModelName());
                    return vo;
                })
                .collect(Collectors.toList());


        //获取石头型号


        //查询水的型号
        List<SysWater> waterModellist = waterService.list();

        // 使用 Set 保证去重
        Set<String> modelSet = waterModellist.stream()
                .map(SysWater::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        // 基于去重后的 model 集合生成 SandFinenessVO 列表
        List<SandFinenessVO> wateModellistVOList = modelSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


//        //获取水泥表 型号
//        List<SysCementModel> cementModellist = sysCementModelService.list();
//        List<SandFinenessVO> cementModels = cementModellist.stream()
//                .map(s -> {
//                    SandFinenessVO vo = new SandFinenessVO();
//                    vo.setValue(s.getSearchValue());
//                    vo.setLabel(s.getModelName());
//                    return vo;
//                })
//                .collect(Collectors.toList());

        //获取水泥表 型号
        List<SysCement> listCement = sysCementService.list();
        // 使用 Set 保证去重
        Set<String> modelCementSet = listCement.stream()
                .map(SysCement::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> cementModellistVOList = modelCementSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //获取水泥表 安全性

        // 使用 Set 保证去重
        Set<String> cementstabilityCementSet = listCement.stream()
                .map(SysCement::getStability) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重

        List<SandFinenessVO> cementStabilitylistVOList = cementstabilityCementSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


//        //水泥 安全性
//        List<SysCementStability> cementStabilityList = sysCementStabilityService.list();
//        List<SandFinenessVO> cementstability = cementStabilityList.stream()
//                .map(s -> {
//                    SandFinenessVO vo = new SandFinenessVO();
//                    vo.setValue(s.getStabilityName());
//                    vo.setLabel(s.getStabilityName());
//                    return vo;
//                })
//                .collect(Collectors.toList());


        //石头型号
//        List<SysStoneModel> listStoneModel = sysStoneModelService.list();
//        List<SandFinenessVO> stoneModel = listStoneModel.stream()
//                .map(s -> {
//                    SandFinenessVO vo = new SandFinenessVO();
//                    vo.setValue(s.getModelName());
//                    vo.setLabel(s.getModelName());
//                    return vo;
//                })
//                .collect(Collectors.toList());

        //石头型号
        List<SysStone> listStone = sysStoneService.list();
        // 使用 Set 保证去重
        Set<String> modelStoneSet = listStone.stream()
                .map(SysStone::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> stoneModellistVOList = modelStoneSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //石头规格
        Set<String> stoneSpecificationSet = listStone.stream()
                .map(SysStone::getStoneSpecification) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> stonestoneSpecificationSetVOList = stoneSpecificationSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //石头颗粒级配
        Set<String> stoneParticleSizeDistributionSet = listStone.stream()
                .map(SysStone::getParticleSizeDistribution) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> stonesParticleSizeDistributionSetVOList = stoneParticleSizeDistributionSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //砂类型
        List<SysSand> listSand = sysSandService.list();
        // 使用 Set 保证去重
        Set<String> sandSet = listSand.stream()
                .map(SysSand::getType) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        // 基于去重后的 model 集合生成 SandFinenessVO 列表
        List<SandFinenessVO> sandTypelistVOList = sandSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //  砂规格
        Set<String> sandGrainSizeSet = listSand.stream()
                .map(SysSand::getGrainSize) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        // 基于去重后的 model 集合生成 SandFinenessVO 列表
        List<SandFinenessVO> sandGrainlistVOList = sandGrainSizeSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //粉煤灰 型号
        List<SysFlyash> listFlyash = sysFlyashService.list();
        // 使用 Set 保证去重
        Set<String> flyashGradelSet = listFlyash.stream()
                .map(SysFlyash::getGrade) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> flyashGradellistVOList = flyashGradelSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //粉煤灰 等级
        Set<String> flyashFactoryGrade = listFlyash.stream()
                .map(SysFlyash::getFactoryGrade) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> flyashFactoryGradelistVOList = flyashFactoryGrade.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //矿粉型号
        List<SysMineralPowder> listMineral = sysMineralPowderService.list();
        Set<String> mineralModel = listMineral.stream()
                .map(SysMineralPowder::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> mineralModellistVOList = mineralModel.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //矿粉矿渣等级
        Set<String> lagGrade = listMineral.stream()
                .map(SysMineralPowder::getSlagGrade) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> minerallagGradelistVOList = lagGrade.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //石头规格
//        List<SysStoneSpecification> listStoneSpecification = sysStoneSpecificationService.list();
//        List<SandFinenessVO> stoneSpecification = listStoneSpecification.stream()
//                .map(s -> {
//                    SandFinenessVO vo = new SandFinenessVO();
//                    vo.setValue(s.getSpecificationName());
//                    vo.setLabel(s.getSpecificationName());
//                    return vo;
//                })
//                .collect(Collectors.toList());


        //石头颗粒级配

//        List<SysStoneParticlesizedistribution> listParticlesizedistribution = sysStoneParticlesizedistributionService.list();
//        List<SandFinenessVO> stoneParticlesizedistribution = listParticlesizedistribution.stream()
//                .map(s -> {
//                    SandFinenessVO vo = new SandFinenessVO();
//                    vo.setValue(s.getParticlesizedistributionName());
//                    vo.setLabel(s.getParticlesizedistributionName());
//                    return vo;
//                })
//                .collect(Collectors.toList());


//        //矿粉型号
//        List<SysMineralModel> listMineralModel = sysMineralModelService.list();
//        List<SandFinenessVO> mineralModel = listMineralModel.stream()
//                .map(s -> {
//                    SandFinenessVO vo = new SandFinenessVO();
//                    vo.setValue(s.getModelName());
//                    vo.setLabel(s.getModelName());
//                    return vo;
//                })
//                .collect(Collectors.toList());

        //其他掺合料 型号


//        List<SysOtherAdmixturesModel> listOtherAdmixturesModel = sysOtherAdmixturesModelService.list();
//        List<SandFinenessVO> otherAdmixturesModel = listOtherAdmixturesModel.stream()
//                .map(s -> {
//                    SandFinenessVO vo = new SandFinenessVO();
//                    vo.setValue(s.getModelName());
//                    vo.setLabel(s.getModelName());
//                    return vo;
//                })
//                .collect(Collectors.toList());

        //其他掺合料 型号
        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();

        // 使用 Set 保证去重
        Set<String> OtherAdmixturesSet = listOtherAdmixtures.stream()
                .map(SysOtherAdmixtures::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> otherModellistVOList = OtherAdmixturesSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        List<SysRegion> regionList = isysRegionService.listRegions();
        Map<String, Object> cementMinAndMax = sysCementService.getCementMinAndMax();
        Map<String, Object> stoneMinAndMax = sysStoneService.getStoneMinAndMax();
        Map<String, Object> flyashMinAndMax = sysFlyashService.queryFlyashMaxMin();
        Map<String, Object> sandMinAndMax = sysSandService.querySandMaxMin();
        Map<String, Object> mineralMinAndMax = sysMineralPowderService.queryMineralMaxMin();
        Map<String, Object> otherMinAndMax = sysOtherAdmixturesService.queryMineralMaxMin();


        HashMap<Object, Object> map = new HashMap<>();


        // map.put("waterOptions", listWaterReducerVOList);  //减水剂类型

//        map.put("listRegion", regionList);  //地区
//
//        //水
//        map.put("sysWaterModel", wateModellistVOList); // 水表 类型名称
//        //水泥
//        map.put("cementModel", cementModels); // 水泥表 类型
//        map.put("cementstability", cementstability);//水泥安全性
//
//        //石头
//        map.put("stoneModel", stoneModel);                                           //石头类型
//        map.put("stoneSpecification", stoneSpecification);                             //石头规格
//        map.put("stoneParticlesizedistribution", stoneParticlesizedistribution);      //石头颗粒级配
////        map.put("listStoneSize", sysStoneSizeVOList);                                 // 石头 石头颗粒级配
////        map.put("stoneGradingOptions", sysStoneGrainVOList);            //石头颗粒级配
//
//        //砂
//        map.put("sandFineOptions", sandFinenessVOList); //砂细度
//        map.put("sandTypeOptions", sandTypeVOList);//砂类型
//
//        //粉煤灰
//        map.put("pfaTypeOptions", sysFlyashTypeVOList); //粉煤灰类型
//        map.put("pfaFineOptions", sysFlyashFinenessesVOList); //粉煤灰等级
//
//        //矿粉
//        map.put("mineralModel", mineralModel);
//
//        // 其他掺合料
//        map.put("otherAdmixturesModel", otherAdmixturesModel); //// 其他掺合料型号


        map.put("listRegion", regionList);  //地区

        //水
        map.put("sysWaterModel", wateModellistVOList); // 水表 类型名称
        //水泥
        map.put("cementModel", cementModellistVOList); // 水泥表 类型
        map.put("cementstability", cementStabilitylistVOList);//水泥安全性

        //石头
        map.put("stoneModel", stoneModellistVOList);                                           //石头类型
        map.put("stoneSpecification", stonestoneSpecificationSetVOList);                             //石头规格
        map.put("stoneParticlesizedistribution", stonesParticleSizeDistributionSetVOList);      //石头颗粒级配
//        map.put("listStoneSize", sysStoneSizeVOList);                                 // 石头 石头颗粒级配
//        map.put("stoneGradingOptions", sysStoneGrainVOList);            //石头颗粒级配

        //砂
        map.put("sandFineOptions", sandGrainlistVOList); //砂规格

        map.put("sandTypeOptions", sandTypelistVOList);//砂类型


        //粉煤灰
        map.put("pfaTypeOptions", flyashGradellistVOList); //粉煤灰类型
        map.put("pfaFineOptions", flyashFactoryGradelistVOList); //粉煤灰等级

        //矿粉
        map.put("mineralModel", mineralModellistVOList); //矿粉型号
        map.put("minerallagGrade", minerallagGradelistVOList);//矿粉 矿渣等级

        // 其他掺合料
        map.put("otherAdmixturesModel", otherModellistVOList); //// 其他掺合料型号

        // 封装石头表数据
        Map<String, Object> stoneDensity = new HashMap<>();
        stoneDensity.put("min", stoneMinAndMax.get("minBulkdensity"));
        stoneDensity.put("max", stoneMinAndMax.get("maxBulkdensity"));


        // 石头堆积密度(kg/m³)
        Map<String, Object> stoneStackingDensity = new HashMap<>();
        stoneStackingDensity.put("min", stoneMinAndMax.get("minStackingDensity"));
        stoneStackingDensity.put("max", stoneMinAndMax.get("maxStackingDensity"));

        // 石头 紧密密度(kg/m³)
        Map<String, Object> stoneCompactDensity = new HashMap<>();
        stoneCompactDensity.put("min", stoneMinAndMax.get("minCompactDensity"));
        stoneCompactDensity.put("max", stoneMinAndMax.get("maxCompactDensity"));


        // 石头 表观密度(kg/m³)
        Map<String, Object> stoneBulkDensity = new HashMap<>();
        stoneBulkDensity.put("min", stoneMinAndMax.get("minBulkDensity"));
        stoneBulkDensity.put("max", stoneMinAndMax.get("maxBulkDensity"));


        // 石头 含泥量(%)
        Map<String, Object> stoneMudContent = new HashMap<>();
        stoneMudContent.put("min", stoneMinAndMax.get("minMudContent"));
        stoneMudContent.put("max", stoneMinAndMax.get("maxMudContent"));

        // 石头 泥块含量(%)
        Map<String, Object> stoneMudChunkContent = new HashMap<>();
        stoneMudChunkContent.put("min", stoneMinAndMax.get("minMudChunkContent"));
        stoneMudChunkContent.put("max", stoneMinAndMax.get("maxMudChunkContent"));

        // 石头 压碎指标值(%)
        Map<String, Object> stoneCrushingIndex = new HashMap<>();
        stoneCrushingIndex.put("min", stoneMinAndMax.get("minCrushingIndex"));
        stoneCrushingIndex.put("max", stoneMinAndMax.get("maxCrushingIndex"));


        // 石头 针片状颗粒含量(%)
        Map<String, Object> stoneNeedleContent = new HashMap<>();
        stoneNeedleContent.put("min", stoneMinAndMax.get("minNeedleContent"));
        stoneNeedleContent.put("max", stoneMinAndMax.get("maxNeedleContent"));


        // 封装水泥表数据
        Map<String, Object> cementCaO = new HashMap<>();
        cementCaO.put("min", cementMinAndMax.get("minCaocontent"));
        cementCaO.put("max", cementMinAndMax.get("maxCaocontent"));

        Map<String, Object> cementSiO2 = new HashMap<>();
        cementSiO2.put("min", cementMinAndMax.get("minSio2content"));
        cementSiO2.put("max", cementMinAndMax.get("maxSio2content"));

        Map<String, Object> cementAl2O3 = new HashMap<>();
        cementAl2O3.put("min", cementMinAndMax.get("minAl2o3content"));
        cementAl2O3.put("max", cementMinAndMax.get("maxAl2o3content"));


        Map<String, Object> cementFineness = new HashMap<>();     // 水泥细度
        cementFineness.put("min", cementMinAndMax.get("minFineness"));
        cementFineness.put("max", cementMinAndMax.get("maxFineness"));


        Map<String, Object> cementStandardConsistency = new HashMap<>();     // 标准稠度
        cementStandardConsistency.put("min", cementMinAndMax.get("minStandardConsistency"));
        cementStandardConsistency.put("max", cementMinAndMax.get("maxStandardConsistency"));


        Map<String, Object> cementStandardTime = new HashMap<>();     // 初凝时间
        cementStandardTime.put("min", cementMinAndMax.get("minInitialSettingTime"));
        cementStandardTime.put("max", cementMinAndMax.get("maxInitialSettingTime"));


        Map<String, Object> cementFinalSettingTime = new HashMap<>();     // 初凝时间
        cementFinalSettingTime.put("min", cementMinAndMax.get("minFinalSettingTime"));
        cementFinalSettingTime.put("max", cementMinAndMax.get("maxFinalSettingTime"));


        Map<String, Object> cementBendingStrength3d = new HashMap<>();     // 3天抗折强度
        cementBendingStrength3d.put("min", cementMinAndMax.get("minBendingStrength3d"));
        cementBendingStrength3d.put("max", cementMinAndMax.get("maxBendingStrength3d"));

        Map<String, Object> cementCompressiveStrength3d = new HashMap<>();     // 3天抗压强度
        cementCompressiveStrength3d.put("min", cementMinAndMax.get("minCompressiveStrength3d"));
        cementCompressiveStrength3d.put("max", cementMinAndMax.get("maxCompressiveStrength3d"));


        Map<String, Object> cementBendingStrength28d = new HashMap<>();     // 3天抗压强度
        cementBendingStrength28d.put("min", cementMinAndMax.get("minBendingStrength28d"));
        cementBendingStrength28d.put("max", cementMinAndMax.get("maxBendingStrength28d"));

        Map<String, Object> cementCompressiveStrength28d = new HashMap<>();     // 3天抗压强度
        cementCompressiveStrength28d.put("min", cementMinAndMax.get("minCompressiveStrength28d"));
        cementCompressiveStrength28d.put("max", cementMinAndMax.get("maxCompressiveStrength28d"));


        Map<String, Object> cementminMortarFlow = new HashMap<>();     // 胶砂流动度
        cementminMortarFlow.put("min", cementMinAndMax.get("minMortarFlow"));
        cementminMortarFlow.put("max", cementMinAndMax.get("maxMortarFlow"));


        //砂
        Map<String, Object> sandFineness = new HashMap<>();     // 砂细度
        sandFineness.put("min", sandMinAndMax.get("minFineness"));
        sandFineness.put("max", sandMinAndMax.get("maxFineness"));

        Map<String, Object> sandMudContent = new HashMap<>();     // 砂含泥量
        sandMudContent.put("min", sandMinAndMax.get("minMudContent"));
        sandMudContent.put("max", sandMinAndMax.get("maxMudContent"));


        Map<String, Object> sandPowderContent = new HashMap<>();     // 砂石粉含量(%)
        sandPowderContent.put("min", sandMinAndMax.get("minStonePowderContent"));
        sandPowderContent.put("max", sandMinAndMax.get("maxStonePowderContent"));


        Map<String, Object> sandMudChunkContent = new HashMap<>();     // 砂 泥块含量(%)
        sandMudChunkContent.put("min", sandMinAndMax.get("minMudChunkContent"));
        sandMudChunkContent.put("max", sandMinAndMax.get("maxMudChunkContent"));


        Map<String, Object> sandBulkDensity = new HashMap<>();     // 砂 堆积密度(kg/m³)
        sandBulkDensity.put("min", sandMinAndMax.get("minBulkDensity"));
        sandBulkDensity.put("max", sandMinAndMax.get("maxBulkDensity"));

        Map<String, Object> sandCompactDensity = new HashMap<>();     // 砂 紧密密度(kg/m³)
        sandCompactDensity.put("min", sandMinAndMax.get("minCompactDensity"));
        sandCompactDensity.put("max", sandMinAndMax.get("maxCompactDensity"));


        Map<String, Object> sandApparentDensity = new HashMap<>();     // 砂 表观密度(kg/m³)
        sandApparentDensity.put("min", sandMinAndMax.get("minApparentDensity"));
        sandApparentDensity.put("max", sandMinAndMax.get("maxApparentDensity"));

        Map<String, Object> sandChlorideIonContent = new HashMap<>();     // 砂 氯离子含量(%)
        sandChlorideIonContent.put("min", sandMinAndMax.get("minChlorideIonContent"));
        sandChlorideIonContent.put("max", sandMinAndMax.get("maxChlorideIonContent"));

        Map<String, Object> sandMethyleneBlueMbValue = new HashMap<>();     // 砂 亚甲蓝MB值(g/kg)
        sandMethyleneBlueMbValue.put("min", sandMinAndMax.get("minMethyleneBlueMbValue"));
        sandMethyleneBlueMbValue.put("max", sandMinAndMax.get("maxMethyleneBlueMbValue"));


        //粉煤灰

        Map<String, Object> flyashFineness = new HashMap<>();     // 煤灰 细度(%)
        flyashFineness.put("min", flyashMinAndMax.get("minFineness"));
        flyashFineness.put("max", flyashMinAndMax.get("maxFineness"));

        Map<String, Object> flyashWaterDemandRatio = new HashMap<>();     // 煤灰 需水量比(%)
        flyashWaterDemandRatio.put("min", flyashMinAndMax.get("minWaterDemandRatio"));
        flyashWaterDemandRatio.put("max", flyashMinAndMax.get("maxWaterDemandRatio"));

        Map<String, Object> flyashLossOnIgnition = new HashMap<>();     // 煤灰 烧失量(%)
        flyashLossOnIgnition.put("min", flyashMinAndMax.get("minLossOnIgnition"));
        flyashLossOnIgnition.put("max", flyashMinAndMax.get("maxLossOnIgnition"));

        Map<String, Object> flyashMoistureContent = new HashMap<>();     // 煤灰 含水量(%)
        flyashMoistureContent.put("min", flyashMinAndMax.get("minMoistureContent"));
        flyashMoistureContent.put("max", flyashMinAndMax.get("maxMoistureContent"));


        Map<String, Object> flyashActivityIndex28d = new HashMap<>();     // 煤灰 28天活性指数(%)
        flyashActivityIndex28d.put("min", flyashMinAndMax.get("minActivityIndex28d"));
        flyashActivityIndex28d.put("max", flyashMinAndMax.get("maxActivityIndex28d"));


        //矿粉
        Map<String, Object> mineralFineness = new HashMap<>();     // 矿粉 细度(%)
        mineralFineness.put("min", mineralMinAndMax.get("minFineness"));
        mineralFineness.put("max", mineralMinAndMax.get("maxFineness"));


        Map<String, Object> mineralFlowRatio = new HashMap<>();     // 矿粉 流动度比(%)
        mineralFlowRatio.put("min", mineralMinAndMax.get("minFlowRatio"));
        mineralFlowRatio.put("max", mineralMinAndMax.get("maxFlowRatio"));


        Map<String, Object> mineralLossOnIgnition = new HashMap<>();     // 矿粉 烧失量(%)
        mineralLossOnIgnition.put("min", mineralMinAndMax.get("minLossOnIgnition"));
        mineralLossOnIgnition.put("max", mineralMinAndMax.get("maxLossOnIgnition"));

        Map<String, Object> mineralMoistureContent = new HashMap<>();     // 矿粉 含水量(%)
        mineralMoistureContent.put("min", mineralMinAndMax.get("minMoistureContent"));
        mineralMoistureContent.put("max", mineralMinAndMax.get("maxMoistureContent"));


        Map<String, Object> mineralActivityIndex28d = new HashMap<>();     // 矿粉 28天活性指数(%)
        mineralActivityIndex28d.put("min", mineralMinAndMax.get("minActivityIndex28d"));
        mineralActivityIndex28d.put("max", mineralMinAndMax.get("maxActivityIndex28d"));


        Map<String, Object> mineralSpecificSurfaceArea = new HashMap<>();     // 矿粉 含水量(%)
        mineralSpecificSurfaceArea.put("min", mineralMinAndMax.get("minSpecificSurfaceArea"));
        mineralSpecificSurfaceArea.put("max", mineralMinAndMax.get("maxSpecificSurfaceArea"));


        // 其他掺合料
        Map<String, Object> otherFineness = new HashMap<>();     // 其他掺合料 细度
        otherFineness.put("min", otherMinAndMax.get("minFineness"));
        otherFineness.put("max", otherMinAndMax.get("maxFineness"));


        Map<String, Object> otherBurnLoss = new HashMap<>();     // 其他掺合料 烧失量(%)
        otherBurnLoss.put("min", otherMinAndMax.get("minBurnLoss"));
        otherBurnLoss.put("max", otherMinAndMax.get("maxBurnLoss"));

        Map<String, Object> otherMoistureContent = new HashMap<>();     // 其他掺合料 含水量(%)
        otherMoistureContent.put("min", otherMinAndMax.get("minMoistureContent"));
        otherMoistureContent.put("max", otherMinAndMax.get("maxMoistureContent"));

        Map<String, Object> otherActivityIndex28d = new HashMap<>();     // 其他掺合料 28天活性指数(%)
        otherActivityIndex28d.put("min", otherMinAndMax.get("minActivityIndex28d"));
        otherActivityIndex28d.put("max", otherMinAndMax.get("maxActivityIndex28d"));

        Map<String, Object> otherSpecificSurfaceArea = new HashMap<>();     // 其他掺合料 比表面积(m²/kg)
        otherSpecificSurfaceArea.put("min", otherMinAndMax.get("minSpecificSurfaceArea"));
        otherSpecificSurfaceArea.put("max", otherMinAndMax.get("maxSpecificSurfaceArea"));


        Map<String, Object> sliderSection = new HashMap<>();
        sliderSection.put("cementCaO", cementCaO);
        sliderSection.put("cementSiO2", cementSiO2);
        sliderSection.put("cementAl2O3", cementAl2O3);

        //获取减水率
        Map<String, Object> waterReducerMinAndMax = sysWaterReducerService.getwaterReducerAndMax();

        // 构建符合要求的返回格式
        Map<String, Object> solidContent = new HashMap<>();
        solidContent.put("min", waterReducerMinAndMax.get("minSolidContent"));
        solidContent.put("max", waterReducerMinAndMax.get("maxSolidContent"));

        Map<String, Object> reducingRate = new HashMap<>();
        reducingRate.put("min", waterReducerMinAndMax.get("minReducingRate"));
        reducingRate.put("max", waterReducerMinAndMax.get("maxReducingRate"));


        //获取粉煤灰最大值最小值
        Map<String, Object> fineness = new HashMap<>();
        fineness.put("min", flyashMinAndMax.get("minFineness"));
        fineness.put("max", flyashMinAndMax.get("maxFineness"));


        // 返回整体结果
        Map<String, Object> result = new HashMap<>();
        result.put("stoneDensity", stoneDensity);
        result.put("cementCaO", cementCaO);
        result.put("cementSiO2", cementSiO2);
        result.put("cementAl2O3", cementAl2O3);
        result.put("includeSolid", solidContent);
        result.put("reducingRate", reducingRate);
        result.put("pfaFine", fineness);
        // 水泥
        result.put("cementFineness", cementFineness); //水泥细度
        result.put("cementStandardConsistency", cementStandardConsistency); //水泥 标准稠度
        result.put("cementStandardTime", cementStandardTime); //水泥 初凝时间
        result.put("cementFinalSettingTime", cementFinalSettingTime); //水泥 终凝时间
        result.put("cementBendingStrength3d", cementBendingStrength3d); //水泥 3天抗折强度
        result.put("cementCompressiveStrength3d", cementCompressiveStrength3d); //水泥 3天抗压强度
        result.put("cementBendingStrength28d", cementBendingStrength28d); //水泥 28天抗折强度
        result.put("cementCompressiveStrength28d", cementCompressiveStrength28d); //水泥 28天抗压强度
        result.put("cementminMortarFlow", cementminMortarFlow); //水泥胶砂流动度

        //石头
        result.put("stoneStackingDensity", stoneStackingDensity); //石头 堆积密度(kg/m³)
        result.put("stoneCompactDensity", stoneCompactDensity); //石头 紧密密度(kg/m³)
        result.put("stoneMudContent", stoneMudContent); //石头  含泥量(%)
        result.put("stoneMudChunkContent", stoneMudChunkContent); //石头     泥块含量(%)
        result.put("stoneCrushingIndex", stoneCrushingIndex); //石头     压碎指标值(%)
        result.put("stoneNeedleContent", stoneNeedleContent); //石头    针片状颗粒含量(%)
        // 砂
        result.put("sandFineness", sandFineness); //砂 砂细度
        result.put("sandMudContent", sandMudContent); //砂 sandMudContent
        result.put("sandPowderContent", sandPowderContent); //砂 砂石粉含量(%)
        result.put("sandMudChunkContent", sandMudChunkContent); //砂 泥块含量(%)
        result.put("sandBulkDensity", sandBulkDensity); //砂    堆积密度(kg/m³)
        result.put("sandCompactDensity", sandCompactDensity); //砂      紧密密度(kg/m³)
        result.put("sandApparentDensity", sandApparentDensity); //砂  表观密度(kg/m³)
        result.put("sandChlorideIonContent", sandChlorideIonContent); //砂 氯离子含量(%)
        result.put("sandMethyleneBlueMbValue", sandMethyleneBlueMbValue); //砂  亚甲蓝MB值(g/kg)

        //煤灰
        result.put("flyashFineness", flyashFineness); // 煤灰 细度(%)
        result.put("flyashWaterDemandRatio", flyashWaterDemandRatio);// 煤灰 需水量比(%)
        result.put("flyashLossOnIgnition", flyashLossOnIgnition); // 煤灰 烧失量(%)
        result.put("flyashMoistureContent", flyashMoistureContent);  // 煤灰 含水量(%)
        result.put("flyashActivityIndex28d", flyashActivityIndex28d); // 煤灰 28天活性指数(%)

        //矿粉
        result.put("mineralFineness", mineralFineness);  // 矿粉 细度(%)
        result.put("mineralFlowRatio", mineralFlowRatio);// 矿粉 流动度比(%)
        result.put("mineralLossOnIgnition", mineralLossOnIgnition); // 矿粉 烧失量(%)
        result.put("mineralMoistureContent", mineralMoistureContent); // 矿粉 含水量(%)
        result.put("mineralActivityIndex28d", mineralActivityIndex28d);// 矿粉 28天活性指数(%)
        result.put("mineralSpecificSurfaceArea", mineralSpecificSurfaceArea);// 矿粉 含水量(%)

        //其他参合料

        result.put("otherFineness", otherFineness);// 其他掺合料 细度
        result.put("otherBurnLoss", otherBurnLoss);// 其他掺合料 烧失量(%)
        result.put("otherMoistureContent", otherMoistureContent);// 其他掺合料 含水量(%)
        result.put("otherActivityIndex28d", otherActivityIndex28d);// 其他掺合料 28天活性指数(%)
        result.put("otherSpecificSurfaceArea", otherSpecificSurfaceArea);// 其他掺合料 比表面积(m²/kg)


        map.put("sliderSection", result); // 最大值 最小值

        return AjaxResult.success(map);
    }


    /**
     * 查询外加剂下拉框
     *
     * @return
     */
    @GetMapping("/listAdditivePullDown")
    public AjaxResult listAdditivePullDown() {

        //减水剂型号
        List<SysWaterReducer> listWaterReducer = sysWaterReducerService.list();
        Set<String> waterReducerSet = listWaterReducer.stream()
                .map(SysWaterReducer::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> wateModellistVOList = waterReducerSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //减水剂商家
        Set<String> waterSourceName = listWaterReducer.stream()
                .map(SysWaterReducer::getSourceName) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> waterSourceNameVOList = waterSourceName.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //增效剂型号
        List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgent.list();
        Set<String> efficiencyAgentSet = listEfficiencyAgent.stream()
                .map(SysEfficiencyAgent::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> agentModel = efficiencyAgentSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //增效剂商家
        Set<String> agentSourceName = listEfficiencyAgent.stream()
                .map(SysEfficiencyAgent::getSourceName) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> agentSourceNameVOList = agentSourceName.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //膨胀剂型号
        List<SysSwellingagent> listSwellingagent = sysSwellingagentService.list();
        Set<String> swellingagentSet = listSwellingagent.stream()
                .map(SysSwellingagent::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> swellingagentModel = swellingagentSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //膨胀剂商家
        Set<String> sysSwellingagentSourceName = listSwellingagent.stream()
                .map(SysSwellingagent::getSourceName) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> sysSwellingagentSourceNameVOList = sysSwellingagentSourceName.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        HashMap<Object, Object> map = new HashMap<>();
        //减水剂
        map.put("waterReducerModel", wateModellistVOList);//减水剂型号
        map.put("waterSourceName", waterSourceNameVOList); //减水剂商家
        //增效剂
        map.put("agentModel", agentModel);//增效剂型号
        map.put("agentSourceName", agentSourceNameVOList); //增效剂商家
        //膨胀剂
        map.put("swellingagentModel", swellingagentModel);//膨胀剂型号
        map.put("swellingagentSource", sysSwellingagentSourceNameVOList); //膨胀剂商家


        // 返回整体结果
        Map<String, Object> result = new HashMap<>();

        //获取减水剂
        Map<String, Object> waterReducerMinAndMax = sysWaterReducerService.getwaterReducerAndMax();
        System.out.println("哈哈哈" + waterReducerMinAndMax);
        // 含固量
        Map<String, Object> solidContent = new HashMap<>();
        solidContent.put("min", waterReducerMinAndMax.get("minSolidContent"));
        solidContent.put("max", waterReducerMinAndMax.get("maxSolidContent"));

        //减水率%
        Map<String, Object> reducingRate = new HashMap<>();
        reducingRate.put("min", waterReducerMinAndMax.get("minReducingRate"));
        reducingRate.put("max", waterReducerMinAndMax.get("maxReducingRate"));


        Map<String, Object> reducingDensity = new HashMap<>();
        reducingDensity.put("min", waterReducerMinAndMax.get("minDensity"));
        reducingDensity.put("max", waterReducerMinAndMax.get("maxDensity"));

        Map<String, Object> reducingCementPasteFlow = new HashMap<>();
        reducingCementPasteFlow.put("min", waterReducerMinAndMax.get("minCementPasteFlow"));
        reducingCementPasteFlow.put("max", waterReducerMinAndMax.get("maxCementPasteFlow"));

        Map<String, Object> reducingPhValue = new HashMap<>();
        reducingPhValue.put("min", waterReducerMinAndMax.get("minPhValue"));
        reducingPhValue.put("max", waterReducerMinAndMax.get("maxPhValue"));

        //减水剂
        result.put("solidContent", solidContent); // 含固量
        result.put("reducingRate", reducingRate); //减水率%
        result.put("reducingDensity", reducingDensity);//密度
        result.put("reducingCementPasteFlow", reducingCementPasteFlow);//水泥净浆流动度
        result.put("reducingPhValue", reducingPhValue); //PH


        map.put("sliderSection", result); // 最大值 最小值
        return AjaxResult.success(map);
    }


    @GetMapping("/listMechanicalPerformancePullDown")
    public AjaxResult listMechanicalPerformancePullDown() {
        // 获取从数据库中查询到的最大值和最小值
        Map<String, Object> efficiencyMerchantMinAndMax = sysEfficiencyMerchantNameService.queryMechanicalPerformanceMaxMin();

        // 构建每个字段的最小值和最大值
        Map<String, Object> compressiveStrength7d = new HashMap<>();
        compressiveStrength7d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength7d"));
        compressiveStrength7d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength7d"));

        Map<String, Object> compressiveStrength28d = new HashMap<>();
        compressiveStrength28d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength28d"));
        compressiveStrength28d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength28d"));

        Map<String, Object> waterContent = new HashMap<>();
        waterContent.put("min", efficiencyMerchantMinAndMax.get("minWaterContent"));
        waterContent.put("max", efficiencyMerchantMinAndMax.get("maxWaterContent"));

        Map<String, Object> cementContent = new HashMap<>();
        cementContent.put("min", efficiencyMerchantMinAndMax.get("minCementContent"));
        cementContent.put("max", efficiencyMerchantMinAndMax.get("maxCementContent"));

        Map<String, Object> flyAshContent = new HashMap<>();
        flyAshContent.put("min", efficiencyMerchantMinAndMax.get("minFlyAshContent"));
        flyAshContent.put("max", efficiencyMerchantMinAndMax.get("maxFlyAshContent"));

        Map<String, Object> sandContent = new HashMap<>();
        sandContent.put("min", efficiencyMerchantMinAndMax.get("minSandContent"));
        sandContent.put("max", efficiencyMerchantMinAndMax.get("maxSandContent"));

        Map<String, Object> stoneContent = new HashMap<>();
        stoneContent.put("min", efficiencyMerchantMinAndMax.get("minStoneContent"));
        stoneContent.put("max", efficiencyMerchantMinAndMax.get("maxStoneContent"));

        Map<String, Object> waterReducerDosage = new HashMap<>();
        waterReducerDosage.put("min", efficiencyMerchantMinAndMax.get("minWaterReducerDosage"));
        waterReducerDosage.put("max", efficiencyMerchantMinAndMax.get("maxWaterReducerDosage"));

        Map<String, Object> efficiencyAgentDosage = new HashMap<>();
        efficiencyAgentDosage.put("min", efficiencyMerchantMinAndMax.get("minEfficiencyAgentDosage"));
        efficiencyAgentDosage.put("max", efficiencyMerchantMinAndMax.get("maxEfficiencyAgentDosage"));


        Map<String, Object> waterDosage = new HashMap<>();
        waterDosage.put("min", efficiencyMerchantMinAndMax.get("minWaterDosage"));
        waterDosage.put("max", efficiencyMerchantMinAndMax.get("maxWaterDosage"));

        Map<String, Object> powderDosage = new HashMap<>();
        powderDosage.put("min", efficiencyMerchantMinAndMax.get("minPowderDosage"));
        powderDosage.put("max", efficiencyMerchantMinAndMax.get("maxPowderDosage"));


        Map<String, Object> admixturesDosage = new HashMap<>();
        admixturesDosage.put("min", efficiencyMerchantMinAndMax.get("minAdmixturesDosage"));
        admixturesDosage.put("max", efficiencyMerchantMinAndMax.get("maxAdmixturesDosage"));



        Map<String, Object> swellingagentDosage = new HashMap<>();
        swellingagentDosage.put("min", efficiencyMerchantMinAndMax.get("minSwellingagentDosage"));
        swellingagentDosage.put("max", efficiencyMerchantMinAndMax.get("maxSwellingagentDosage"));



        // 获取ID列表并转换为所需格式
        Function<List<Integer>, List<Map<String, String>>> convertToValueLabelList = list ->
                list.stream()
                        .map(id -> {
                            Map<String, String> item = new HashMap<>();
                            item.put("value", String.valueOf(id));
                            item.put("label", String.valueOf(id));
                            return item;
                        })
                        .collect(Collectors.toList());

        List<Map<String, String>> regionIdList = convertToValueLabelList.apply(
                isysRegionService.listRegions().stream().map(SysRegion::getRegionId).collect(Collectors.toList())
        );

        List<Map<String, String>> cementIdList = convertToValueLabelList.apply(
                sysCementService.listCement().stream().map(SysCement::getCementId).collect(Collectors.toList())
        );
        System.out.println("哈哈哈"+cementIdList);


        List<Map<String, String>> sandIdList = convertToValueLabelList.apply(
                sysSandService.listSand().stream().map(SysSand::getSandId).collect(Collectors.toList())
        );

        List<Map<String, String>> stoneIdList = convertToValueLabelList.apply(
                sysStoneService.listStones().stream()
                        .map(SysStone::getStoneId)
                        .collect(Collectors.toList())


        );

        List<Map<String, String>> waterReducerList = convertToValueLabelList.apply(
                sysWaterReducerService.listWaterReduce().stream()
                        .map(reducer -> reducer.getReducerId().intValue())
                        .collect(Collectors.toList())
        );

        List<Map<String, String>> flyashIdList = convertToValueLabelList.apply(
                sysFlyashService.listFlyash().stream().map(SysFlyash::getFlyashId).collect(Collectors.toList())
        );

        List<Map<String, String>> efficiencyAgentIdList = convertToValueLabelList.apply(
                sysEfficiencyAgent.listefficiencyAgents().stream()
                        .map(agent -> agent.getAgentId().intValue())
                        .collect(Collectors.toList())
        );




        List<SysRegion> regionList = isysRegionService.listRegions();

        Map<String, Object> idList = new HashMap<>();
        idList.put("regionIdList", regionIdList);
        idList.put("cementIdList", cementIdList);
        idList.put("sandIdList", sandIdList);
        idList.put("stoneIdList", stoneIdList);
        idList.put("waterReducerList", waterReducerList);
        idList.put("flyashIdList", flyashIdList);
        idList.put("efficiencyAgentIdList", efficiencyAgentIdList);
        idList.put("regionList", regionList);

      //  idList.put("waterModelList", waterModelList);//水型号







        // 构建返回结果
        Map<String, Object> sliderSection = new HashMap<>();
        sliderSection.put("compressive7d", compressiveStrength7d);
        sliderSection.put("compressive28d", compressiveStrength28d);
        sliderSection.put("waterContent", waterContent);
        sliderSection.put("cementContent", cementContent);
        sliderSection.put("flyAshContent", flyAshContent);
        sliderSection.put("sandContent", sandContent);
        sliderSection.put("stoneContent", stoneContent);
        sliderSection.put("waterReducerDosage", waterReducerDosage);
        sliderSection.put("synergyDosage", efficiencyAgentDosage);

        sliderSection.put("waterDosage", waterDosage);//水掺量（%）
        sliderSection.put("powderDosage", powderDosage);///矿粉掺量
        sliderSection.put("admixturesDosage", admixturesDosage);//其他参合料掺量
        sliderSection.put("swellingagentDosage", swellingagentDosage);//膨胀剂掺量




/*
        // 水泥
        List<SysCement> sysCementList = sysCementService.listCement();
        List<Map<String, Object>> cementIdListPlus = new ArrayList<>();
        for (SysCement sysCement : sysCementList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysCement.getModel());
            labelValueMap.put("value", sysCement.getModel());
            cementIdListPlus.add(labelValueMap);
        }

        // 地区
        List<SysRegion> listRegion = isysRegionService.listRegions();
        List<Map<String, Object>> listRegionList = new ArrayList<>();
        for (SysRegion sysRegion : listRegion) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getRegionName());
            labelValueMap.put("value", sysRegion.getRegionName());

            listRegionList.add(labelValueMap);
        }


        List<SysSand> listSysSands = sysSandService.listSand();

        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        for (SysSand sysRegion : listSysSands) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getType());
            labelValueMap.put("value", sysRegion.getType());

            listSysSandLists.add(labelValueMap);
        }

        //石头
        List<SysStone> sysStoneList = sysStoneService.listStones();

        List<Map<String, Object>> listStoneList = new ArrayList<>();
        for (SysStone sysStone : sysStoneList) {
            Map<String, Object> labelStoneValueMaps = new HashMap<>();
            labelStoneValueMaps.put("label", sysStone.getParticleSizeDistribution());
            labelStoneValueMaps.put("value", sysStone.getParticleSizeDistribution());
            listStoneList.add(labelStoneValueMaps);
        }

        //减水剂
        List<SysWaterReducer> reducers = sysWaterReducerService.listWaterReduce();
        List<Map<String, Object>> listWaterList = new ArrayList<>();
        for (SysWaterReducer reducer : reducers) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", reducer.getModel());
            labelValueMap.put("value", reducer.getModel());
            listWaterList.add(labelValueMap);
        }

        List<SysFlyash> sysFlyashList = sysFlyashService.listFlyash();
        List<Map<String, Object>> listFlyashList = new ArrayList<>();
        for (SysFlyash sysFlyash : sysFlyashList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysFlyash.getGrade());
            labelValueMap.put("value", sysFlyash.getGrade());
            listFlyashList.add(labelValueMap);

        }


        List<SysEfficiencyAgent> efficiencyAgents = sysEfficiencyAgent.listefficiencyAgents();

        List<Map<String, Object>> efficiencyAgentList = new ArrayList<>();
        for (SysEfficiencyAgent efficiencyAgent : efficiencyAgents) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", efficiencyAgent.getModel());
            labelValueMap.put("value", efficiencyAgent.getModel());
            efficiencyAgentList.add(labelValueMap);
        }

        // 水型号
        List<Map<String, Object>> waterModelList = new ArrayList<>();
        List<SysWater> listWaterModelList = waterService.list();
        for (SysWater sysWater : listWaterModelList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            waterModelList.add(labelValueMap);

        }
        //矿粉型号
        List<Map<String, Object>> mineralPowderList = new ArrayList<>();
        List<SysMineralPowder> listMineralPowderList = sysMineralPowderService.list();
        for (SysMineralPowder sysWater : listMineralPowderList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            mineralPowderList.add(labelValueMap);

        }

        //其他型号
        List<Map<String, Object>> otherAdmixturesList = new ArrayList<>();
        List<SysOtherAdmixtures> listOtherAdmixturesList = sysOtherAdmixturesService.list();
        for (SysOtherAdmixtures sysWater : listOtherAdmixturesList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            waterModelList.add(labelValueMap);

        }

        //膨胀剂型号
        List<Map<String, Object>> swellingagentList = new ArrayList<>();
        List<SysSwellingagent> listSwellingagentList = sysSwellingagentService.list();
        for (SysSwellingagent sysWater : listSwellingagentList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            swellingagentList.add(labelValueMap);

        }*/






// 水泥
        List<SysCement> sysCementList = sysCementService.listCement();
        List<Map<String, Object>> cementIdListPlus = new ArrayList<>();
        Set<String> cementModels = new HashSet<>();
        for (SysCement sysCement : sysCementList) {
            String model = sysCement.getModel();
            if (cementModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                cementIdListPlus.add(labelValueMap);
            }
        }


        List<SysRegion> listRegion = isysRegionService.listRegions();
        List<Map<String, Object>> listRegionList = new ArrayList<>();
        for (SysRegion sysRegion : listRegion) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getRegionId());
            labelValueMap.put("value", sysRegion.getRegionName());
            listRegionList.add(labelValueMap);
        }

// 砂类型
        List<SysSand> listSysSands = sysSandService.listSand();
        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        Set<String> sandTypes = new HashSet<>();
        for (SysSand sysSand : listSysSands) {
            String type = sysSand.getType();
            if (sandTypes.add(type)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", type);
                labelValueMap.put("value", type);
                listSysSandLists.add(labelValueMap);
            }
        }

// 石头类型
        List<SysStone> sysStoneList = sysStoneService.listStones();
        List<Map<String, Object>> listStoneList = new ArrayList<>();
        Set<String> stoneDistributions = new HashSet<>();
        for (SysStone sysStone : sysStoneList) {
            String distribution = sysStone.getParticleSizeDistribution();
            if (stoneDistributions.add(distribution)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", distribution);
                labelValueMap.put("value", distribution);
                listStoneList.add(labelValueMap);
            }
        }

// 减水剂
        List<SysWaterReducer> reducers = sysWaterReducerService.listWaterReduce();
        List<Map<String, Object>> listWaterList = new ArrayList<>();
        Set<String> waterReducerModels = new HashSet<>();
        for (SysWaterReducer reducer : reducers) {
            String model = reducer.getModel();
            if (waterReducerModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                listWaterList.add(labelValueMap);
            }
        }

// 粉煤灰
        List<SysFlyash> sysFlyashList = sysFlyashService.listFlyash();
        List<Map<String, Object>> listFlyashList = new ArrayList<>();
        Set<String> flyashGrades = new HashSet<>();
        for (SysFlyash sysFlyash : sysFlyashList) {
            String grade = sysFlyash.getGrade();
            if (flyashGrades.add(grade)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", grade);
                labelValueMap.put("value", grade);
                listFlyashList.add(labelValueMap);
            }
        }

// 高效剂
        List<SysEfficiencyAgent> efficiencyAgents = sysEfficiencyAgent.listefficiencyAgents();
        List<Map<String, Object>> efficiencyAgentList = new ArrayList<>();
        Set<String> efficiencyAgentModels = new HashSet<>();
        for (SysEfficiencyAgent efficiencyAgent : efficiencyAgents) {
            String model = efficiencyAgent.getModel();
            if (efficiencyAgentModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                efficiencyAgentList.add(labelValueMap);
            }
        }

// 水型号
        List<SysWater> listWaterModelList = waterService.list();
        List<Map<String, Object>> waterModelList = new ArrayList<>();
        Set<String> waterModels = new HashSet<>();
        for (SysWater sysWater : listWaterModelList) {
            String model = sysWater.getModel();
            if (waterModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                waterModelList.add(labelValueMap);
            }
        }

// 矿粉型号
        List<SysMineralPowder> listMineralPowderList = sysMineralPowderService.list();
        List<Map<String, Object>> mineralPowderList = new ArrayList<>();
        Set<String> mineralPowderModels = new HashSet<>();
        for (SysMineralPowder sysMineralPowder : listMineralPowderList) {
            String model = sysMineralPowder.getModel();
            if (mineralPowderModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                mineralPowderList.add(labelValueMap);
            }
        }

// 其他型号
        List<SysOtherAdmixtures> listOtherAdmixturesList = sysOtherAdmixturesService.list();
        List<Map<String, Object>> otherAdmixturesList = new ArrayList<>();
        Set<String> otherAdmixtureModels = new HashSet<>();
        for (SysOtherAdmixtures sysOtherAdmixtures : listOtherAdmixturesList) {
            String model = sysOtherAdmixtures.getModel();
            if (otherAdmixtureModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                otherAdmixturesList.add(labelValueMap);
            }
        }

// 膨胀剂型号
        List<SysSwellingagent> listSwellingagentList = sysSwellingagentService.list();
        List<Map<String, Object>> swellingagentList = new ArrayList<>();
        Set<String> swellingagentModels = new HashSet<>();
        for (SysSwellingagent sysSwellingagent : listSwellingagentList) {
            String model = sysSwellingagent.getModel();
            if (swellingagentModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                swellingagentList.add(labelValueMap);
            }
        }



        // 创建 idsPlus 并填充数据
        Map<String, Object> idListPlus = new HashMap<>();
        idListPlus.put("regionIdList", listRegionList);
        idListPlus.put("cementIdList", cementIdListPlus);
        idListPlus.put("sandIdList", listSysSandLists);
        idListPlus.put("stoneIdList", listStoneList);
        idListPlus.put("waterReducerList", listWaterList);
        idListPlus.put("flyashIdList", listFlyashList);
        idListPlus.put("efficiencyAgentIdList", efficiencyAgentList);
        idListPlus.put("regionList", "");

        idListPlus.put("waterModel", waterModelList);//水
        idListPlus.put("mineralModel",mineralPowderList );//矿粉
        idListPlus.put("otherAdmixturesModel", otherAdmixturesList);//其他型号
        idListPlus.put("swellingagentModel",swellingagentList );//    //其他型号


        Map<String, Object> result = new HashMap<>();
        // result.put("ids", idList);
        result.put("sliderSection", sliderSection);
        result.put("ids", idListPlus);
        return AjaxResult.success(result);


    }


    /**
     * 查询力学性能最大值 最小值
     * @return
     */

/*
    @GetMapping("/listMechanicalPerformancePullDown")
    public AjaxResult listMechanicalPerformancePullDown() {

        // 获取从数据库中查询到的最大值和最小值
        Map<String, Object> efficiencyMerchantMinAndMax = sysEfficiencyMerchantNameService.queryMechanicalPerformanceMaxMin();

        // 构建每个字段的最小值和最大值
        Map<String, Object> compressiveStrength7d = new HashMap<>();
        compressiveStrength7d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength7d"));
        compressiveStrength7d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength7d"));

        Map<String, Object> compressiveStrength28d = new HashMap<>();
        compressiveStrength28d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength28d"));
        compressiveStrength28d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength28d"));

        Map<String, Object> waterContent = new HashMap<>();
        waterContent.put("min", efficiencyMerchantMinAndMax.get("minWaterContent"));
        waterContent.put("max", efficiencyMerchantMinAndMax.get("maxWaterContent"));

        Map<String, Object> cementContent = new HashMap<>();
        cementContent.put("min", efficiencyMerchantMinAndMax.get("minCementContent"));
        cementContent.put("max", efficiencyMerchantMinAndMax.get("maxCementContent"));

        Map<String, Object> flyAshContent = new HashMap<>();
        flyAshContent.put("min", efficiencyMerchantMinAndMax.get("minFlyAshContent"));
        flyAshContent.put("max", efficiencyMerchantMinAndMax.get("maxFlyAshContent"));

        Map<String, Object> sandContent = new HashMap<>();
        sandContent.put("min", efficiencyMerchantMinAndMax.get("minSandContent"));
        sandContent.put("max", efficiencyMerchantMinAndMax.get("maxSandContent"));

        Map<String, Object> stoneContent = new HashMap<>();
        stoneContent.put("min", efficiencyMerchantMinAndMax.get("minStoneContent"));
        stoneContent.put("max", efficiencyMerchantMinAndMax.get("maxStoneContent"));

        Map<String, Object> waterReducerDosage = new HashMap<>();
        waterReducerDosage.put("min", efficiencyMerchantMinAndMax.get("minWaterReducerDosage"));
        waterReducerDosage.put("max", efficiencyMerchantMinAndMax.get("maxWaterReducerDosage"));
        HashMap<Object, Object> map = new HashMap<>();



        Map<String, Object> efficiencyAgentDosage = new HashMap<>();
        efficiencyAgentDosage.put("min", efficiencyMerchantMinAndMax.get("minEfficiencyAgentDosage"));
        efficiencyAgentDosage.put("max", efficiencyMerchantMinAndMax.get("maxEfficiencyAgentDosage"));




        // 获取地区列表id列表
        List<SysRegion> regionList = isysRegionService.listRegions();
        List<Integer> regionIdList = regionList.stream()
                .map(SysRegion::getRegionId)
                .collect(Collectors.toList());






        //获取水泥id列表
        List<SysCement> sysCementList  = sysCementService.listCement();
        List<Integer> cementIdList = sysCementList.stream()
                .map(SysCement::getCementId)
                .collect(Collectors.toList());


        //砂 id列表
        List<SysSand> sysSands = sysSandService.listSand();
        List<Integer> sysSandIdList = sysSands.stream()
                .map(SysSand::getSandId)
                .collect(Collectors.toList());


        //石头
        List<SysStone> sysStoneList = sysStoneService.listStones();
        List<Integer> stoneIdList = sysStoneList.stream()
                .map(SysStone::getStoneId)
                .collect(Collectors.toList());

        //减水剂id列表
        List<SysWaterReducer> sysWaterReducerList = sysWaterReducerService.listWaterReduce();
        List<Integer> waterReducerList = sysWaterReducerList.stream()
                .map(reducer -> reducer.getReducerId().intValue()) // 使用 intValue() 方法进行转换
                .collect(Collectors.toList());

        //粉煤灰
        List<SysFlyash> flyashList = sysFlyashService.listFlyash();
        List<Integer>flyashIdList = flyashList.stream()
                .map(SysFlyash::getFlyashId)
                .collect(Collectors.toList());

        List<SysEfficiencyAgent> sysEfficiencyAgentList = sysEfficiencyAgent.listefficiencyAgents();
        List<Integer> efficiencyAgentIdList = sysEfficiencyAgentList.stream()
                .map(agent -> agent.getAgentId().intValue()) // Convert Long to Integer
                .collect(Collectors.toList());






        HashMap<Object, Object> idList = new HashMap<>();
        idList.put("regionIdList",regionIdList);
        idList.put("cementIdList",cementIdList);
        idList.put("sandIdList",sysSandIdList);
        idList.put("stoneIdList",stoneIdList);
        idList.put("waterReducerList",waterReducerList);
        idList.put("flyashIdList",flyashIdList);
        idList.put("efficiencyAgentIdList",efficiencyAgentIdList);


        // 将所有的结果封装到最终的返回 Map 中
        Map<String, Object> result = new HashMap<>();
        result.put("compressive7d", compressiveStrength7d);
        result.put("compressive28d", compressiveStrength28d);
        result.put("waterContent", waterContent);
        result.put("cementContent", cementContent);
        result.put("flyAshContent", flyAshContent);
        result.put("sandContent", sandContent);
        result.put("stoneContent", stoneContent);
        result.put("waterDosage", waterReducerDosage);
        map.put("sliderSection",result);
        result.put("synergyDosage", efficiencyAgentDosage);

        map.put("ids",idList);
        return AjaxResult.success(map);
    }
*/

    /**
     * 力学性能下拉框
     * @return
     */
//    @GetMapping("/listMechanicalPerformancePullDown")
//    public AjaxResult listMechanicalPerformancePullDown() {
//
//        // 获取从数据库中查询到的最大值和最小值
//        Map<String, Object> efficiencyMerchantMinAndMax = sysEfficiencyMerchantNameService.queryMechanicalPerformanceMaxMin();
//
//        // 构建每个字段的最小值和最大值
//        Map<String, Object> compressiveStrength7d = new HashMap<>();
//        compressiveStrength7d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength7d"));
//        compressiveStrength7d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength7d"));
//
//        Map<String, Object> compressiveStrength28d = new HashMap<>();
//        compressiveStrength28d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength28d"));
//        compressiveStrength28d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength28d"));
//
//        Map<String, Object> waterContent = new HashMap<>();
//        waterContent.put("min", efficiencyMerchantMinAndMax.get("minWaterContent"));
//        waterContent.put("max", efficiencyMerchantMinAndMax.get("maxWaterContent"));
//
//        Map<String, Object> cementContent = new HashMap<>();
//        cementContent.put("min", efficiencyMerchantMinAndMax.get("minCementContent"));
//        cementContent.put("max", efficiencyMerchantMinAndMax.get("maxCementContent"));
//
//        Map<String, Object> flyAshContent = new HashMap<>();
//        flyAshContent.put("min", efficiencyMerchantMinAndMax.get("minFlyAshContent"));
//        flyAshContent.put("max", efficiencyMerchantMinAndMax.get("maxFlyAshContent"));
//
//        Map<String, Object> sandContent = new HashMap<>();
//        sandContent.put("min", efficiencyMerchantMinAndMax.get("minSandContent"));
//        sandContent.put("max", efficiencyMerchantMinAndMax.get("maxSandContent"));
//
//        Map<String, Object> stoneContent = new HashMap<>();
//        stoneContent.put("min", efficiencyMerchantMinAndMax.get("minStoneContent"));
//        stoneContent.put("max", efficiencyMerchantMinAndMax.get("maxStoneContent"));
//
//        Map<String, Object> waterReducerDosage = new HashMap<>();
//        waterReducerDosage.put("min", efficiencyMerchantMinAndMax.get("minWaterReducerDosage"));
//        waterReducerDosage.put("max", efficiencyMerchantMinAndMax.get("maxWaterReducerDosage"));
//        HashMap<Object, Object> map = new HashMap<>();
//
//        Map<String, Object> efficiencyAgentDosage = new HashMap<>();
//        waterReducerDosage.put("min", efficiencyMerchantMinAndMax.get("maxEfficiencyAgentDosage"));
//        waterReducerDosage.put("max", efficiencyMerchantMinAndMax.get("minEfficiencyAgentDosage"));
//
//
//
//
//        // 获取地区列表id列表
//        List<SysRegion> regionList = isysRegionService.listRegions();
//        List<Integer> regionIdList = regionList.stream()
//                .map(SysRegion::getRegionId)
//                .collect(Collectors.toList());
//
//          //获取水泥id列表
//        List<SysCement> sysCementList  = sysCementService.listCement();
//        List<Integer> cementIdList = sysCementList.stream()
//                .map(SysCement::getCementId)
//                .collect(Collectors.toList());
//
//
//        //砂 id列表
//        List<SysSand> sysSands = sysSandService.listSand();
//        List<Integer> sysSandIdList = sysSands.stream()
//                .map(SysSand::getSandId)
//                .collect(Collectors.toList());
//
//
//        //石头
//        List<SysStone> sysStoneList = sysStoneService.listStones();
//        List<Integer> stoneIdList = sysStoneList.stream()
//                .map(SysStone::getStoneId)
//                .collect(Collectors.toList());
//
//        //减水剂id列表
//        List<SysWaterReducer> sysWaterReducerList = sysWaterReducerService.listWaterReduce();
//        List<Integer> waterReducerList = sysWaterReducerList.stream()
//                .map(reducer -> reducer.getReducerId().intValue()) // 使用 intValue() 方法进行转换
//                .collect(Collectors.toList());
//
//        //粉煤灰
//        List<SysFlyash> flyashList = sysFlyashService.listFlyash();
//        List<Integer>flyashIdList = flyashList.stream()
//                .map(SysFlyash::getFlyashId)
//                .collect(Collectors.toList());
//
//
//
//        HashMap<Object, Object> idList = new HashMap<>();
//        idList.put("regionIdList",regionIdList);
//        idList.put("cementIdList",cementIdList);
//        idList.put("sandIdList",sysSandIdList);
//        idList.put("stoneIdList",stoneIdList);
//        idList.put("waterReducerList",waterReducerList);
//        idList.put("flyashIdList",flyashIdList);
//
//        // 将所有的结果封装到最终的返回 Map 中
//        Map<String, Object> result = new HashMap<>();
//        result.put("compressive7d", compressiveStrength7d);
//        result.put("compressive28d", compressiveStrength28d);
//        result.put("waterContent", waterContent);
//        result.put("cementContent", cementContent);
//        result.put("flyAshContent", flyAshContent);
//        result.put("sandContent", sandContent);
//        result.put("stoneContent", stoneContent);
//        result.put("waterDosage", waterReducerDosage);
//        map.put("sliderSection",result);
//        result.put("synergyDosage", efficiencyAgentDosage);
//
//
//        map.put("ids",idList);
//        return AjaxResult.success(map);
//    }


    /**
     * 查询外加剂原材料信息
     */

//    @GetMapping("/listAdditivePullDown")
//    public AjaxResult listAdditivePullDown() {
//
//        List<SysWaterReducer> waterReducerList = sysWaterReducerService.listWaterReduce();
//        List<SandFinenessVO> sysFlyashFinenessesVOList = waterReducerList.stream()
//                .map(s -> {
//                    SandFinenessVO vo = new SandFinenessVO();
//                    vo.setValue(s.getSourceName());
//                    vo.setLabel(s.getSourceName());
//                    return vo;
//                })
//                .collect(Collectors.toList());
//
//
//        HashMap<Object, Object> map = new HashMap<>();
//        map.put("waterReducerOptions", sysFlyashFinenessesVOList);
//
//        return AjaxResult.success(map);
//    }


    /**
     * 导出原材料excel
     */
//    @PostMapping("exportRawMaterialsExcel")
//    public AjaxResult exportRawMaterialsExcel(@RequestBody RawMaterialsDTO rawMaterialsDTO){
//        List<Integer> cementIds = rawMaterialsDTO.getCementIds();
//     List<SysCement> listCementList=   sysCementService.listCementByIds(cementIds);
//
//
//
//
//        // 创建一个 Excel 工作簿
//        Workbook workbook = new XSSFWorkbook();
//        // 创建一个 Sheet，并命名为 "水泥"
//        Sheet sheet = workbook.createSheet("水泥");
//
//
//
//
//
//        return AjaxResult.success(listCementList);
//    }
    @PostMapping("exportRawMaterialsExcel1")
    public AjaxResult exportRawMaterialsExcel1(@RequestBody RawMaterialsDTO rawMaterialsDTO) {

        // 获取水泥ID列表
        List<Integer> cementIds = rawMaterialsDTO.getCementIds();
        List<Integer> sandIds = rawMaterialsDTO.getSandIds();
        List<Integer> stoneIds = rawMaterialsDTO.getStoneIds();
        List<Integer> flyashIds = rawMaterialsDTO.getFlyashIds();
        List<Integer> waterReducerIds = rawMaterialsDTO.getWaterReducerIds();


        // 获取水泥数据
        List<SysCement> listCementList = sysCementService.listCementByIds(cementIds);
        List<SysStone> listStoneList = sysStoneService.listStoneByIds(stoneIds);
        List<SysSand> listSandList = sysSandService.listSandByIds(sandIds);
        List<SysFlyash> listFlyasList = sysFlyashService.listFlyashIds(flyashIds);
        List<SysWaterReducer> waterReducerList = sysWaterReducerService.listWaterReduceIds(waterReducerIds);


// 将所有数据放入 Map 中
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("cementList", listCementList);
        resultMap.put("stoneList", listStoneList);
        resultMap.put("sandList", listSandList);
        resultMap.put("flyashList", listFlyasList);
        resultMap.put("waterReducerList", waterReducerList);

        return AjaxResult.success(resultMap);
    }

//    @PostMapping("exportRawMaterialsExcel")
//    public ResponseEntity<byte[]> exportRawMaterialsExcel(@RequestBody RawMaterialsDTO rawMaterialsDTO) throws IOException, UnsupportedEncodingException {
//        // 获取水泥ID列表
//        List<Integer> cementIds = rawMaterialsDTO.getCementIds();
//        List<Integer> sandIds = rawMaterialsDTO.getSandIds();
//        List<Integer> stoneIds = rawMaterialsDTO.getStoneIds();
//        List<Integer> flyashIds = rawMaterialsDTO.getFlyashIds();
//        List<Integer> waterReducerIds = rawMaterialsDTO.getWaterReducerIds();
//
//
//        // 获取水泥数据
//        List<SysCement> listCementList = sysCementService.listCementByIds(cementIds);
//        List<SysStone>  listStoneList  =sysStoneService.listStoneByIds(stoneIds);
//        List<SysSand> listSandList = sysSandService.listSandByIds(sandIds);
//        List<SysFlyash>    listFlyasList      = sysFlyashService.listFlyashIds(flyashIds);
//        List<SysWaterReducer>  waterReducerList    = sysWaterReducerService.listWaterReduceIds(waterReducerIds);
//
//
//
//
//
//        // 创建一个 Excel 工作簿
//        Workbook workbook = new XSSFWorkbook();
//        // 创建一个 Sheet，并命名为 "水泥"
//        Sheet sheet = workbook.createSheet("水泥");
//
//        // 设置表头
//        Row headerRow = sheet.createRow(0);
//        headerRow.createCell(0).setCellValue("水泥ID");
//        headerRow.createCell(1).setCellValue("型号");
//        headerRow.createCell(2).setCellValue("CaO含量 (%)");
//        headerRow.createCell(3).setCellValue("SiO2含量 (%)");
//        headerRow.createCell(4).setCellValue("Al2O3含量 (%)");
//        headerRow.createCell(5).setCellValue("地区");
//        headerRow.createCell(6).setCellValue("地区名称");
//
//        // 填充数据
//        int rowNum = 1;
//        for (SysCement cement : listCementList) {
//            Row row = sheet.createRow(rowNum++);
//            row.createCell(0).setCellValue(cement.getCementId());
//            row.createCell(1).setCellValue(cement.getModel());
//            row.createCell(2).setCellValue(cement.getCaoContent());
//            row.createCell(3).setCellValue(cement.getSio2Content());
//            row.createCell(4).setCellValue(cement.getAl2o3Content());
//            row.createCell(5).setCellValue(cement.getRegionName());
//            row.createCell(6).setCellValue(cement.getRegionNameStr());
//        }
//
//        // 将 Excel 数据写入字节数组输出流
//        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
//        workbook.write(byteArrayOutputStream);
//        byteArrayOutputStream.close();
//
//// 获取 Excel 文件数据
//        byte[] excelData = byteArrayOutputStream.toByteArray();
//
//// 确保字节数组包含有效的 Excel 文件内容
//        String fileName = "水泥数据.xlsx";  // 文件名
//
//
//        // 对文件名进行 URL 编码
//        String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"); // 替换 "+" 为 "%20"
//
//        // 设置响应头，并返回 Excel 文件
//// 设置响应头，指示这是一个 Excel 文件并需要下载
//        HttpHeaders headers = new HttpHeaders();
//        headers.add("Content-Disposition", "attachment; filename=水泥数据.xlsx");
//        headers.add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
//
//        return ResponseEntity.ok()
//                .headers(headers)
//                .body(excelData);
//    }


    /**
     * 导出原材料excel
     *
     * @param rawMaterialsDTO
     * @return
     * @throws IOException
     * @throws UnsupportedEncodingException
     */
    @PostMapping("exportRawMaterialsExcel")
    public ResponseEntity<byte[]> exportRawMaterialsExcel(@RequestBody RawMaterialsDTO rawMaterialsDTO) throws IOException, UnsupportedEncodingException {
        // 获取各类原材料的 ID 列表
        List<Integer> cementIds = rawMaterialsDTO.getCementIds();
        List<Integer> sandIds = rawMaterialsDTO.getSandIds();
        List<Integer> stoneIds = rawMaterialsDTO.getStoneIds();
        List<Integer> flyashIds = rawMaterialsDTO.getFlyashIds();
        List<Integer> waterReducerIds = rawMaterialsDTO.getWaterReducerIds();

        // 根据 ID 列表查询数据
        List<SysCement> cementList = sysCementService.listCementByIds(cementIds);
        List<SysStone> stoneList = sysStoneService.listStoneByIds(stoneIds);
        List<SysSand> sandList = sysSandService.listSandByIds(sandIds);
        List<SysFlyash> flyashList = sysFlyashService.listFlyashIds(flyashIds);
        List<SysWaterReducer> waterReducerList = sysWaterReducerService.listWaterReduceIds(waterReducerIds);

        // 创建一个 Excel 工作簿
        Workbook workbook = new XSSFWorkbook();

        // 创建不同 sheet 并填充数据
        createCementSheet(workbook, cementList);
        createStoneSheet(workbook, stoneList);
        createSandSheet(workbook, sandList);
        createFlyashSheet(workbook, flyashList);
        createWaterReducerSheet(workbook, waterReducerList);

        // 将 Excel 数据写入字节数组输出流
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        workbook.write(byteArrayOutputStream);
        byteArrayOutputStream.close();

        byte[] excelData = byteArrayOutputStream.toByteArray();
        String fileName = "原材料数据.xlsx";

        // 对文件名进行 URL 编码
        String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");

        // 设置响应头，返回 Excel 文件
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Disposition", "attachment; filename=" + encodedFileName);
        headers.add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

        return ResponseEntity.ok()
                .headers(headers)
                .body(excelData);
    }

    // 工具方法：创建水泥 sheet
    private void createCementSheet(Workbook workbook, List<SysCement> cementList) {
        Sheet sheet = workbook.createSheet("水泥");
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("水泥ID");
        headerRow.createCell(1).setCellValue("型号");
        headerRow.createCell(2).setCellValue("CaO含量 (%)");
        headerRow.createCell(3).setCellValue("SiO2含量 (%)");
        headerRow.createCell(4).setCellValue("Al2O3含量 (%)");
        headerRow.createCell(5).setCellValue("地区名称");

        int rowNum = 1;
        for (SysCement cement : cementList) {
            Row row = sheet.createRow(rowNum++);
            row.createCell(0).setCellValue(cement.getCementId());
            row.createCell(1).setCellValue(cement.getModel());
//            row.createCell(2).setCellValue(cement.getCaoContent());
//            row.createCell(3).setCellValue(cement.getSio2Content());
//            row.createCell(4).setCellValue(cement.getAl2o3Content());
            row.createCell(5).setCellValue(cement.getRegionNameStr());
        }
    }

    // 工具方法：创建石子 sheet
    private void createStoneSheet(Workbook workbook, List<SysStone> stoneList) {
        Sheet sheet = workbook.createSheet("石子");
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("石子ID");
        headerRow.createCell(1).setCellValue("表观密度");

        headerRow.createCell(2).setCellValue("颗粒级配");
        headerRow.createCell(3).setCellValue("颗粒尺寸");
        headerRow.createCell(4).setCellValue("地区名称");

        int rowNum = 1;
        for (SysStone stone : stoneList) {
            Row row = sheet.createRow(rowNum++);
            row.createCell(0).setCellValue(stone.getStoneId());
            row.createCell(1).setCellValue(stone.getBulkDensity());

            row.createCell(2).setCellValue(stone.getParticleSizeDistribution());

            row.createCell(3).setCellValue(stone.getSize());
            row.createCell(4).setCellValue(stone.getRegionNameStr());
        }
    }

    // 工具方法：创建砂子 sheet
    private void createSandSheet(Workbook workbook, List<SysSand> sandList) {
        Sheet sheet = workbook.createSheet("砂子");
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("砂子ID");
        headerRow.createCell(1).setCellValue("砂细度");
        headerRow.createCell(2).setCellValue("砂类型");
        headerRow.createCell(3).setCellValue("地区名称");

        int rowNum = 1;
        for (SysSand sand : sandList) {
            Row row = sheet.createRow(rowNum++);
            row.createCell(0).setCellValue(sand.getSandId());
            row.createCell(1).setCellValue(sand.getGrainSize());
            row.createCell(2).setCellValue(sand.getType());
            row.createCell(3).setCellValue(sand.getRegionNameStr());
        }
    }

    // 工具方法：创建粉煤灰 sheet
    private void createFlyashSheet(Workbook workbook, List<SysFlyash> flyashList) {
        Sheet sheet = workbook.createSheet("粉煤灰");
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("粉煤灰ID");
        headerRow.createCell(1).setCellValue("型号");
        headerRow.createCell(2).setCellValue("细度");
        headerRow.createCell(3).setCellValue("地区名称");

        int rowNum = 1;
        for (SysFlyash flyash : flyashList) {
            Row row = sheet.createRow(rowNum++);
            row.createCell(0).setCellValue(flyash.getFlyashId());
            row.createCell(1).setCellValue(flyash.getGrade());
            row.createCell(2).setCellValue(flyash.getRegionName());
            row.createCell(3).setCellValue(flyash.getRegionNameStr());
        }
    }

    // 工具方法：创建减水剂 sheet
    private void createWaterReducerSheet(Workbook workbook, List<SysWaterReducer> waterReducerList) {
        Sheet sheet = workbook.createSheet("减水剂");
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("减水剂ID");
        headerRow.createCell(1).setCellValue("类型");
        headerRow.createCell(2).setCellValue("含固量");
        headerRow.createCell(3).setCellValue("减水率");
        headerRow.createCell(4).setCellValue("来源名称");

        int rowNum = 1;
        for (SysWaterReducer reducer : waterReducerList) {
            Row row = sheet.createRow(rowNum++);
            row.createCell(0).setCellValue(reducer.getReducerId());
            row.createCell(1).setCellValue(reducer.getModel());
//            row.createCell(2).setCellValue(reducer.getSolidContent());
//            row.createCell(3).setCellValue(reducer.getReducingRate());
            row.createCell(4).setCellValue(reducer.getRegionNameStr());
        }
    }


    /**
     * 外加剂导出 excel
     *
     * @param
     * @return
     * @throws IOException
     * @throws UnsupportedEncodingException
     */
    @PostMapping("exportAdditiveExcel")
    public ResponseEntity<byte[]> exportAdditiveExcel(@RequestBody AdditiveDTO additiveDTO) throws IOException, UnsupportedEncodingException {
        // 获取各类原材料的 ID 列表

        List<Integer> waterReducerIds = additiveDTO.getWaterReducerIds();
        List<Integer> agentIds = additiveDTO.getAgentIds();

        List<SysWaterReducer> waterReducerList = sysWaterReducerService.listWaterReduceIds(waterReducerIds);
        List<SysEfficiencyAgent> EfficiencyAgentList = sysEfficiencyAgent.listeEfficiencyAgent(agentIds);


        // 创建一个 Excel 工作簿
        Workbook workbook = new XSSFWorkbook();
        createWaterReducerSheet(workbook, waterReducerList);

        createEfficiencyAgentSheet(workbook, EfficiencyAgentList);
        // 将 Excel 数据写入字节数组输出流
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        workbook.write(byteArrayOutputStream);
        byteArrayOutputStream.close();

        byte[] excelData = byteArrayOutputStream.toByteArray();
        String fileName = "外加剂数据.xlsx";

        // 对文件名进行 URL 编码
        String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");

        // 设置响应头，返回 Excel 文件
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Disposition", "attachment; filename=" + encodedFileName);
        headers.add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

        return ResponseEntity.ok()
                .headers(headers)
                .body(excelData);
    }


    // 工具方法：创建增效剂 sheet
    private void createEfficiencyAgentSheet(Workbook workbook, List<SysEfficiencyAgent> waterReducerList) {
        Sheet sheet = workbook.createSheet("增效剂");
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("增效剂ID");
        headerRow.createCell(1).setCellValue("类型");
        headerRow.createCell(2).setCellValue("来源名称");

        int rowNum = 1;
        for (SysEfficiencyAgent reducer : waterReducerList) {
            Row row = sheet.createRow(rowNum++);
            row.createCell(0).setCellValue(reducer.getAgentId());
            row.createCell(1).setCellValue(reducer.getModel());
            row.createCell(2).setCellValue(reducer.getRegionNameStr());
        }
    }


    /**
     * 测试用
     *
     * @param additiveDTO
     * @return
     * @throws IOException
     * @throws UnsupportedEncodingException
     */
    @PostMapping("AdditiveList")
    public AjaxResult AdditiveList(@RequestBody AdditiveDTO additiveDTO) throws IOException, UnsupportedEncodingException {
        // 获取各类原材料的 ID 列表

        List<Integer> waterReducerIds = additiveDTO.getWaterReducerIds();
        List<Integer> agentIds = additiveDTO.getAgentIds();

        List<SysWaterReducer> waterReducerList = sysWaterReducerService.listWaterReduceIds(waterReducerIds);
        List<SysEfficiencyAgent> EfficiencyAgentList = sysEfficiencyAgent.listeEfficiencyAgent(agentIds);


        HashMap<Object, Object> map = new HashMap<>();
        map.put("waterReducerList", waterReducerList);
        map.put("EfficiencyAgentList", EfficiencyAgentList);
        return AjaxResult.success(map);
    }


}
